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 #96

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Laravel 11.x Shift #96

wants to merge 19 commits into from

Conversation

Jnesselr
Copy link
Member

@Jnesselr Jnesselr commented Nov 9, 2024

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

Before merging, you need to:

  • Checkout the shift-132964 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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_CONNECTION=mysql
MAIL_MAILER=smtp
QUEUE_CONNECTION=sync
REDIS_QUEUE_RETRY_AFTER=900
SESSION_DRIVER=file

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

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ Shift was unable to re-register your exception handler. You may review the documentation to do so manually, or register your original exception handler by adding the following binding to the register method of your AppServiceProvider:

$this->app->bind(\Illuminate\Contracts\Debug\ExceptionHandler::class, \App\Exceptions\Handler::class);

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

❌ The app/Console/Kernel.php file has been removed in Laravel 11. 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. If so, you may re-apply them to the routes/console.php file or the new bootstrap/app.php file. Review the documentation for additional details.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

The following dependencies were not updated by Shift and may be incompatible. If Composer lists one of these packages as a problem, you should check for a newer version.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ Laravel 10 has added a return type of array to the Event broadcastOn and Notification via methods. However, you may still return a single channel from these methods.

Shift added the array return type to these methods in the following classes. You should review them to ensure you are returning an array, or remove the return type.

  • app/Notifications/CardAccessAllowedButNotAMemberRedAlert.php
  • app/Notifications/CardAccessDeniedBadDoor.php
  • app/Notifications/CardAccessDeniedBecauseNotAMember.php
  • app/Notifications/CardAccessDeniedButWereWorkingOnIt.php
  • app/Notifications/CardAccessDeniedNoWaiver.php
  • app/Notifications/GitHubInviteExpired.php
  • app/Notifications/IdCheckedWithNoWaiver.php
  • app/Notifications/NewRequirementsWaiverNeeded.php
  • app/Notifications/OctoPrintNewUser.php

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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 8d3377b0

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ Laravel 11 has removed its dependency on doctrine/dbal. Shift detected your project contains this dependency. If you are not using this package directly or were only using it for change migrations, you may remove it by running: composer remove doctrine/dbal

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ Many first-party Laravel packages no longer load their migrations automatically. Instead, you may need to publish their migrations to your application if you have not already done so. Shift detected you are using Passport. You may run the following command to publish their migrations:

php artisan vendor:publish --tag=passport-migrations

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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 keep your application modern and make future maintenance easier.

  • app/Http/Middleware/TrustProxies.php

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ Many of the default drivers changed in Laravel 11. For example, the default database driver is sqlite and the default cache store is database. If you experience errors setting up your environment, be sure you have properly set your ENV variables for these drivers. If you wish to adopt the new defaults, you may follow the documentation to set them up for your application.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

ℹ️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

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

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

⚠️ 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.

@Jnesselr
Copy link
Member Author

Jnesselr commented Nov 9, 2024

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

@Jnesselr
Copy link
Member Author

Had to remove Laravel websockets as its deprecated. Will switch to Laravel Reverb. Composer lists a few other outdated packages I'll take a look at as part of this update.

doctrine/dbal                   3.9.3   4.2.1  Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
hashids/hashids                 4.1.0   5.0.2  Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers
predis/predis                   1.1.10  2.2.2  Flexible and feature-complete Redis client for PHP and HHVM
slack-php/slack-block-kit       0.19.0  2.1.0  OOP interface for writing Slack Block Kit messages and modals
spatie/ssl-certificate          1.22.1  2.6.8  A class to easily query the properties of an ssl certificate
stripe/stripe-php               7.128.0 16.2.0 Stripe PHP Library

@Jnesselr
Copy link
Member Author

Need to check on this middleware, as it's giving a warning that the /Middleware/ part does not exist.

'feature' => \YlsIdeas\FeatureFlags\Middleware\FeatureFlagState::class,

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.

2 participants