home / skills / 1weiho / laravel-upgrade-skill / laravel-upgrade

laravel-upgrade skill

/skills/laravel-upgrade

This skill upgrades Laravel applications one major version at a time by detecting current version and applying targeted fixes and guidance.

npx playbooks add skill 1weiho/laravel-upgrade-skill --skill laravel-upgrade

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
3.1 KB
---
name: laravel-upgrade
description: Upgrade Laravel applications one major version at a time (9→10, 10→11, 11→12). Use when user wants to upgrade their Laravel framework version. Auto-detects current version from composer.json, identifies breaking changes, and applies necessary code fixes.
---

# Laravel Upgrade

Upgrade Laravel applications one major version at a time. Supports: 9→10, 10→11, 11→12.

## Workflow

### 1. Detect Current Version

Read `composer.json` and find the `laravel/framework` version constraint:

```php
// Example: "laravel/framework": "^10.0" means Laravel 10.x
```

Determine target version (current + 1). If already on Laravel 12, inform user they're on the latest supported version.

### 2. Load Upgrade Guide

Based on detected versions, read the appropriate reference file:

| Current | Target | Reference File |
|---------|--------|----------------|
| 9.x | 10.x | [references/from-9-to-10.md](references/from-9-to-10.md) |
| 10.x | 11.x | [references/from-10-to-11.md](references/from-10-to-11.md) |
| 11.x | 12.x | [references/from-11-to-12.md](references/from-11-to-12.md) |

### 3. Scan and Fix

For each breaking change in the guide, scan the codebase and apply fixes:

**High Impact** (always check):
- `composer.json` dependency versions
- PHP version requirements
- Database migrations using deprecated methods

**Medium Impact** (check relevant files):
- Model `$dates` property → `$casts` (9→10)
- Database expressions with `(string)` casting (9→10)
- Column modification migrations missing attributes (10→11)
- `HasUuids` trait behavior change (11→12)

**Low Impact** (check if patterns found):
- Deprecated method calls (`Bus::dispatchNow`, `Redirect::home`, etc.)
- Contract interface changes
- Configuration file updates

### 4. Update Dependencies

After code fixes, update `composer.json`:

```bash
# Update laravel/framework constraint to target version
# Update related packages per upgrade guide
composer update
```

### 5. Post-Upgrade Verification

- Run `php artisan` to verify framework boots
- Run test suite if available
- Check for deprecation warnings in logs

## Common Patterns

### Dependency Updates (all upgrades)

Search `composer.json` for outdated constraints and update per guide.

### Model $dates to $casts (9→10)

```php
// Before
protected $dates = ['deployed_at'];

// After
protected $casts = ['deployed_at' => 'datetime'];
```

Search pattern: `protected \$dates\s*=`

### Database Expression Casting (9→10)

```php
// Before
$string = (string) DB::raw('select 1');

// After
$string = DB::raw('select 1')->getValue(DB::connection()->getQueryGrammar());
```

### Column Modification (10→11)

Migrations using `->change()` must now include all modifiers:

```php
// Before (implicit retention)
$table->integer('votes')->nullable()->change();

// After (explicit)
$table->integer('votes')->unsigned()->default(1)->nullable()->change();
```

### HasUuids Trait (11→12)

```php
// Before (ordered UUIDv4)
use Illuminate\Database\Eloquent\Concerns\HasUuids;

// After (if you need UUIDv4 behavior)
use Illuminate\Database\Eloquent\Concerns\HasVersion4Uuids as HasUuids;
```

Overview

This skill upgrades Laravel applications one major version at a time (9→10, 10→11, 11→12). It auto-detects the current Laravel version from composer.json, reads the appropriate upgrade reference, and applies targeted code and dependency fixes to complete the major-version bump.

How this skill works

The skill reads composer.json to detect the laravel/framework constraint and determines the next major target. It loads a version-specific reference file containing breaking changes and scan patterns. For each listed change it locates affected files, applies automated code fixes where safe, and updates composer.json dependencies. Finally it runs post-upgrade checks such as boot verification and test execution suggestions.

When to use it

  • When you need to upgrade Laravel one major release at a time (9→10, 10→11, 11→12).
  • Before performing a major upgrade to identify and apply breaking-change fixes automatically.
  • When you want dependency and PHP requirement updates applied consistently with the upgrade guide.
  • When you need a quick scan for common upgrade patterns and automatic fixes to migration, model, and config code.
  • When preparing a codebase for CI test runs after a major framework bump.

Best practices

  • Commit or snapshot the repository before running the upgrade to enable easy rollback.
  • Run the skill one major version at a time, following the detected current → next target flow.
  • Run the full test suite and manual smoke tests after the upgrade to catch runtime issues.
  • Review automated fixes, especially for migrations and UUID behavior, before deploying to production.
  • Update PHP and related package constraints in composer.json to match the new Laravel requirements.

Example use cases

  • Upgrade an app from Laravel 10.x to 11.x: detect ^10.0 in composer.json, apply migration modifier fixes, update composer constraints.
  • Migrate model date handling from $dates to $casts when moving 9.x to 10.x.
  • Fix deprecated method calls and configuration changes when preparing an app for Laravel 12.
  • Adjust HasUuids usage for projects that require UUIDv4 when upgrading 11→12.
  • Automate bulk dependency updates and run composer update after code fixes.

FAQ

What versions does the skill support?

It supports incremental upgrades 9→10, 10→11, and 11→12. If the project is already on Laravel 12, it reports that you are on the latest supported version.

Will the skill change migrations or production data?

The skill modifies migration code to satisfy new modifiers but does not run migrations against databases. Always review changes and run migrations in a controlled environment.