nikspyratos / toybox

Opinionated TALL stack starter kit for Laravel solopreneurs
MIT License
117 stars 6 forks source link

Laravel 11.x Shift #6

Closed nikspyratos closed 4 months ago

nikspyratos commented 4 months ago

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

Before merging, you need to:

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

:warning: The application bootstrapping has changed in Laravel 11. As a result, files like artisan and public/index.php were rewritten. Shift overwrote these files but detected yours may have contained customizations. You should review the diff to see if any of your customizations are still needed.

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

BCRYPT_ROUNDS=10
CACHE_STORE=file
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
DB_CONNECTION=mysql
MAIL_MAILER=smtp
PUSHER_APP_ID=app-id
PUSHER_APP_KEY=app-key
PUSHER_APP_SECRET=app-secret
PUSHER_HOST=127.0.0.1
PUSHER_PORT=6001
PUSHER_SCHEME=http
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_SECURE_COOKIE=true

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.

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

:x: The bootstrap/app.php file has been completely rewritten in Laravel 11 to allow customizing your Laravel application. Shift overwrote your file but detected it may have contained customizations. You should review the diff to see if any of your customizations are still needed.

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

: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 5afe41b9

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

: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
nikspyratos commented 4 months ago

: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 within database.php, you may remove this configuration file.

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

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

nikspyratos commented 4 months ago

:tada: 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:

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