newznab-tmux icon indicating copy to clipboard operation
newznab-tmux copied to clipboard

Laravel 11.x Shift

Open DariusIII opened this issue 1 year ago • 21 comments

This pull request provides a preview of the upcoming changes for upgrading to Laravel 11. Laravel 11 is not yet released. While you are encouraged to review and test the shift-111609 branch, it should not be merged.

To review:

  • Checkout the shift-111609 branch
  • Review all pull request comments for additional changes
  • Run composer update (if the scripts fail, add --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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: To slim down the Laravel installation, Laravel 11 no longer includes most of the core files previously included in the default Laravel application. While you are welcome to publish and customize these files, they are not 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: Laravel 9 moved the resources/lang folder to the top level of the project. While Shift moved and replaced references to this folder, you may have additional references to this folder which need to be updated.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: Laravel 11 no longer requires you to maintain the default configuration files. Your configuration now merges with framework defaults. So you only need to set custom values in your own configuration files. In addition, there are new ENV variables in Laravel 11 to set commonly customized values, such as APP_TIMEZONE, DB_CHARSET, and LOG_STACK.

Shift streamlined your configuration files by removing those that matched the Laravel defaults and preserving your true customizations. These include values which are not changeable through ENV variables. You should review these changes carefully and ensure you set ENV variables for any customized values.

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 remaking your customizations.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: The BROADCAST_DRIVER and CACHE_DRIVER environment variable were renamed in Laravel 11 to BROADCAST_CONNECTION and CACHE_STORE, 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:x: Shift detected you are using laravelcollective/html. This package has been abandoned. They suggest using the spatie/laravel-html package instead. You may use Shift's HTML Converter to automate this conversion. However, if you are not using the laravelcollective/html package extensively, you may simply rewrite its uses to raw HTML.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: 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.

The following dependencies were updated by a major version and may have their own changes. You may check their changelog for any additional upgrade steps.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: Shift detected your application has a test suite. To allow your to verify the upgrade in isolation, Shift did not bump your testing dependencies for PHPUnit 10. Once you have completed your upgrade, you may run the PHPUnit 10 Shift for free to upgrade your test suite to PHPUnit 10 separately.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: Laravel 9 adopted anonymous migrations. Shift automated this change to align with modern Laravel conventions and avoid naming migrations.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: Starting with Laravel 10, PHP type hints were added within classes included in a Laravel application. In an effort to modernize your code, Shift automated this change where Laravel strictly specifies a type. If you prefer not to type hint your code you may revert this commit by running: git revert 917dffcd

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:x: Laravel 11 has removed its dependency on doctrine/dbal. As such, all of Laravel's classes and methods related Doctrine DBAL have been removed.

Shift detected potential uses of these within the following files. You should review these instances and, if they are still needed, reference the Upgrade Guide for native alternatives.

  • [ ] database/migrations/2020_03_07_213224_remove_text_hash.php

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: In Laravel 11, changing a column now requires you to include all the modifiers you want to keep on the column definition after it is changed. Any missing attributes will be dropped. This change may cause unexpected behavior if you were to run pending or old migrations.

Shift detected potential uses of the change method within your migrations. While you may go back and update these migrations, you may wish to simply squash your old migrations. This will not only avoid rework, but may also improve the performance of your test suite.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:x: Many first-party Laravel packages no longer automatically load their migrations. Instead you need to publish their migrations to your application. Shift detected you are using Sanctum and Telescope. You may run the following command to publish their migrations:

php artisan vendor:publish --tag=sanctum-migrations
php artisan vendor:publish --tag=telescope-migrations

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: 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, you may remove the configuration file.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: The following files previously included in a Laravel application appeared to be customized and were not removed. Shift encourages you to review your customizations to see if they are still needed or may be done elsewhere in a modern Laravel application. Removing these files will not only help your application feel fresh, but make future maintenance easier.

  • [ ] app/Exceptions/Handler.php
  • [ ] app/Http/Middleware/Authenticate.php
  • [ ] app/Http/Middleware/RedirectIfAuthenticated.php
  • [ ] app/Http/Middleware/TrimStrings.php
  • [ ] app/Http/Middleware/VerifyCsrfToken.php
  • [ ] app/Providers/RouteServiceProvider.php

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:information_source: 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. However, if you experience issues relating to Symfony, you should review the Symfony change log for any additional changes.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: 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.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:warning: Shift detected you are using a Laravel package like Horizon or Nova which may need to have its published assets regenerated after upgrading. Be sure to use artisan to republish these assets as well as php artisan view:clear to avoid any errors.

DariusIII avatar Mar 07 '24 14:03 DariusIII

:alembic: This Shift is still being refined. Please report any issues or suggestions to [email protected]. Your feedback is what helps improve the experience for everyone.

DariusIII avatar Mar 07 '24 14:03 DariusIII