Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 11.x Shift #138

Merged
merged 16 commits into from
Mar 15, 2024
Merged

Laravel 11.x Shift #138

merged 16 commits into from
Mar 15, 2024

Conversation

mikaeljorhult
Copy link
Owner

This pull request includes the changes for upgrading to Laravel 11.x. Feel free to commit any additional changes to the shift-112773 branch.

Before merging, you need to:

  • Checkout the shift-112773 branch
  • Review all pull request comments for additional changes
  • Run composer update (if the scripts fail, try with --no-scripts)
  • Clear any config, route, or view cache
  • Thoroughly test your application (no tests?, no CI?)

If you need help with your upgrade, check out the Human Shifts.

@mikaeljorhult
Copy link
Owner Author

ℹ️ To slim down the Laravel installation, Laravel 11 no longer has most of the core files previously included in the default Laravel application. While you are welcome to publish and customize these files, they are no longer required.

Shift takes an iterative approach to removing core files which are not customized or where its customizations may be done elsewhere in a modern Laravel 11 application. As such, you may see some commits removing files and others re-registering your customizations.

@mikaeljorhult
Copy link
Owner Author

ℹ️ Laravel 11 no longer requires you to maintain the default configuration files. Your configuration now merges with framework defaults.

Shift streamlined your configuration files by removing options that matched the Laravel defaults and preserving your true customizations. These are values which are not changeable through ENV variables.

If you wish to keep the full set of configuration files, Shift recommends running artisan config:publish --all --force to get the latest configuration files from Laravel 11, then reapplying the customizations Shift streamlined.

@mikaeljorhult
Copy link
Owner Author

ℹ️ Shift detected customized options within your configuration files which may be set with an ENV variable. To help keep your configuration files streamlined, you may set the following variables. Be sure adjust any values per environment.

ARGON_MEMORY=1024
ARGON_THREADS=2
ARGON_TIME=2
BCRYPT_ROUNDS=10
CACHE_STORE=file
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
DB_CONNECTION=mysql
MAIL_MAILER=smtp
QUEUE_CONNECTION=sync
SESSION_DRIVER=file

Note: some of these may simply be values which changed between Laravel 10 and Laravel 11. You may ignore any ENV variables you do not need to customize.

@mikaeljorhult
Copy link
Owner Author

⚠️ The BROADCAST_DRIVER, CACHE_DRIVER, and DATABASE_URL environment variables were renamed in Laravel 11 to BROADCAST_CONNECTION, CACHE_STORE, and DB_URL, respectively.

Shift automated this change for your committed files, but you should review any additional locations where your environment is configured and update to the new variable names.

@mikaeljorhult
Copy link
Owner Author

⚠️ Laravel 11 automatically discovers policies scanning your application's Policies directory at or above the directory containing your models.

Shift detected policies registered with the policies property of your AuthServiceProvider. If any of these policies can not be automatically discovered, you may register them manually using Gate::policy() in your AppServiceProvider.

@mikaeljorhult
Copy link
Owner Author

⚠️ Laravel 11 automatically discovers events by scanning your application's Listeners directory.

Shift detected event listeners registered with the listen property of your EventServiceProvider. If any of these listeners can not be automatically discovered, you may register them manually using Event::listen() in your AppServiceProvider.

@mikaeljorhult
Copy link
Owner Author

⚠️ Shift detected a custom route registry in your RouteServiceProvider. In Laravel 11 you may quickly register web and api routes, as well as set the API prefix. If you need to register additional routes, you may do so with the then callback. If you need to customize all your routes, you may register your routes with the using callback.

You should review your custom routes to see if you need to use one of these callbacks or if your customizations may be done within the route file. You may reference the documentation on Route Customization for more details on these callbacks.

Route::middleware('web')
    ->group(base_path('routes/web.php'));

Route::prefix('api')
    ->middleware('api')
    ->group(base_path('routes/api.php'));

@mikaeljorhult
Copy link
Owner Author

ℹ️ Shift updated your dependencies for Laravel 11. While many of the popular packages are reviewed, you may have to update additional packages in order for your application to be compatible with Laravel 11. Watch dealing with dependencies for tips on handling any Composer issues.

@mikaeljorhult
Copy link
Owner Author

ℹ️ The base Controller class has been marked as abstract in Laravel 11, with its traits and inheritance removed. This is to prevent using this base controller directly and to use facades instead of the trait methods.

Shift detected your base controller did not have any public methods, so it was safe to mark as abstract. However, since you may be using trait methods within your controllers, Shift did not remove them. If you know you are not using any trait methods or want to refactor to facades, you may remove them manually.

@mikaeljorhult
Copy link
Owner Author

⚠️ The CreatesApplication testing trait has been removed in Laravel 11. Its createApplication method is now defined in the TestCase class. To avoid a conflict, Shift removed this method from your CreatesApplication trait. You should review this change to see if you need any code from the original method.

@mikaeljorhult
Copy link
Owner Author

ℹ️ Laravel 11 now updates the timestamp when publishing vendor migrations. This may cause problems in existing applications when these migrations were previously published and ran with their default timestamp.

To preserve the original behavior, Shift disabled this feature in your database.php configuration file. If you do not have any vendor migrations or have squashed all of your existing migrations, you may re-enable the update_date_on_publish option. If this is the only customization within database.php, you may remove this configuration file.

@mikaeljorhult
Copy link
Owner Author

⚠️ Previously, Laravel would append a colon (:) to any cache key prefix for DynamoDB, Memcache, or Redis. Laravel 11 no longer appends a colon to your cache key prefix. If you are using one of these stores, you should append a colon to your prefix to avoid invalidating your cache.

@mikaeljorhult
Copy link
Owner Author

ℹ️ All of the underlying Symfony components used by Laravel have been upgraded to Symfony 7.0. Shift detected references to Symfony classes within your application. These are most likely type hints and can safely be ignored. If you are using Symfony classes directly or experience issues relating to Symfony, you should review the Symfony change log for any additional changes.

@mikaeljorhult
Copy link
Owner Author

⚠️ Laravel 11 requires PHP 8.2 or higher. You should verify the PHP version in your environments to ensure it meets this new requirement.

@mikaeljorhult
Copy link
Owner Author

⚠️ Laravel 11 now includes a database driver for MariaDB. Previously the MySQL driver offered parity with MariaDB. However, with MariaDB 10.1, there are more database specific features available. If you are using MariaDB, you may want to evaluate this new mariadb driver after completing your upgrade to Laravel 11.

@mikaeljorhult
Copy link
Owner Author

🎉 Congratulations, you're now running the latest version of Laravel!

Next, you may optionally run the following Shifts to ensure your application is fully upgraded, adopts the latest Laravel conventions, and easier to maintain in the future:

  • Laravel Fixer automatically updates your code to the latest Laravel conventions.
  • Tests Generator intelligently generates model factories, HTTP Tests, and configuration for your application.
  • CI Generator intelligently generates CI jobs to lint PHP, check code style, and run tests, including Dusk.

You may also use the Shift Workbench to automate common tasks for maintaining your Laravel application.

@mikaeljorhult mikaeljorhult merged commit 8748f57 into main Mar 15, 2024
1 check failed
@mikaeljorhult mikaeljorhult deleted the shift-112773 branch March 15, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants