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 9.x Shift #109

Merged
merged 25 commits into from
Feb 9, 2022
Merged

Laravel 9.x Shift #109

merged 25 commits into from
Feb 9, 2022

Conversation

dsbilling
Copy link
Member

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

Before merging, you need to:

  • Checkout the shift-55308 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. You may also join the Shifty Coders Slack workspace to level-up your Laravel skills.

Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] config to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started.

For more information on customizing the code style applied by Shift, [watch this short video][4].

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://github.com/squizlabs/PHP_CodeSniffer
[3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
[4]: https://laravelshift.com/videos/shift-code-style
Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods.
In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.
`<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI.

Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/
@dsbilling
Copy link
Member Author

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

@dsbilling
Copy link
Member Author

⚠️ Laravel 9 upgraded to Flysystem 3.0 causing the behavior of the Storage facade to change slightly:

  • Write operations (such as put and write) now overwrite existing files by default.
  • Read operations (such as get and download) now return null instead of a FileNotFoundException when a file is missing.
  • The delete operation now returns true even if the file did not exist.

For more details, you may review the Flysystem 3.x section of the Upgrade Guide.

@dsbilling
Copy link
Member Author

⚠️ Laravel 9 transitioned from SwiftMailer to Symfony Mailer. While this transition should be relatively seamless and Shift automates any tedious changes, there are some changes which are not reliably automated.

Dependencies
Some mail providers may require an additional dependency. For example, if you are using Mailgun, then you will need to install the symfony/mailgun-mailer package:

composer require symfony/mailgun-mailer

Updated Return Types
The send, html, text, and plain methods no longer return the number of recipients that received the message.

Failed Recipients
It is no longer possible to retrieve a list of failed recipients after sending a message. Instead, a Symfony\Component\Mailer\Exception\TransportExceptionInterface exception will be thrown if a message fails to send. Instead of relying on retrieving invalid email addresses after sending a message, it is recommend that you validate email addresses before sending the message instead.

For more details on what has changed you may review the Symfony Mailer section of the Upgrade Guide.

@dsbilling
Copy link
Member Author

dsbilling commented Feb 9, 2022

❌ Shift could not upgrade the following files since they differed from the default Laravel version. You will need to compare these files against the default Laravel 9 versions and merge any changes:

  • lang/en/auth.php
  • lang/en/validation.php

@dsbilling
Copy link
Member Author

ℹ️ Laravel 8 removed the public/web.config file. The presence of this file creates a potential security risk for projects not using Microsoft IIS as their web server.

Shift detected this file was unmodified and removed it. If you are using Microsoft IIS as your web server, you may undo this commit by running git revert 922b7680.

@dsbilling
Copy link
Member Author

⚠️ The FILESYSTEM_DRIVER environment variable was renamed to FILESYSTEM_DISK in Laravel 9. Shift attempted to automate this change, but you should review any additional environment configuration and rename this variable.

@dsbilling
Copy link
Member Author

⚠️ Shift upgraded your configuration files by defaulting them and merging your true customizations. These include values which are not changeable through core ENV variables.

You should review this commit for additional customizations or opportunities to use new ENV variables. If you have a lot of customizations, you may undo this commit with git revert 6183e3b9 and make the config file changes manually.

@dsbilling
Copy link
Member Author

ℹ️ The FILESYSTEM_CLOUD environment variable was removed in a later release of Laravel 8. While you may still use the cloud disk, you are encouraged to configure your own disks.

@dsbilling
Copy link
Member Author

⚠️ The token driver for API authentication is no longer available. This driver was not very robust and was removed from the documentation. Laravel now recommends using Sanctum.

If you were using the token driver, you may re-add it within your auth.php configuration file, then migrate to Sanctum at your convenience.

@dsbilling
Copy link
Member Author

ℹ️ Shift updated your dependencies for Laravel 9. 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 9.

Watch dealing with dependencies for tips on handling any additional package incompatibilities.

@dsbilling
Copy link
Member Author

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

@dsbilling
Copy link
Member Author

dsbilling commented Feb 9, 2022

⚠️ The $loop variable is no longer available when iterating over a LazyCollection. Shift detected the $loop variable being used in the following Blade templates. You should review these instances to ensure they are not iterating over a LazyCollection or track your own loop variables.

  • resources/views/vendor/scribe/partials/example-requests/bash.md.blade.php
  • resources/views/vendor/scribe/partials/example-requests/python.md.blade.php

@dsbilling
Copy link
Member Author

ℹ️ The HTTP client has been updated to have a default timeout of 30 seconds. Previously there was no default. The underlying request would wait indefinitely. Now an exception is thrown after 30 seconds.

If you find your requests need longer, you may prefix your request to specify a timeout:

Http::timeout(60)->get("https://laravelshift.com");

@dsbilling
Copy link
Member 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:

  • Upgrade Checker ensures your application is fully upgraded by detecting any outdated code.
  • 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 and PHP applications.

@dsbilling dsbilling merged commit ee0d049 into laravel-9 Feb 9, 2022
@dsbilling dsbilling deleted the shift-55308 branch February 9, 2022 15:16
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.

3 participants