Skip to content

Laravel 8.x Shift - #3021

Merged
ssddanbrown merged 19 commits into
laravel_8_upgradefrom
shift-51221
Oct 30, 2021
Merged

ssddanbrown merged 19 commits into
laravel_8_upgradefrom
shift-51221

Conversation

@ssddanbrown

Copy link
Copy Markdown
Member

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

Before merging, you need to:

  • Checkout the shift-51221 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.
From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html
@ssddanbrown

Copy link
Copy Markdown
Member Author

⚠️ Shift detected a custom namespace. Laravel now recommends keeping the default App namespace. While it was available to customize in previous versions using app:name, this command was removed in Laravel 6.

Shift recommends changing this to align with Laravel and improve its automation. After doing so, you are welcome to request a rerun of this Shift.

@ssddanbrown

ssddanbrown commented Oct 28, 2021

Copy link
Copy Markdown
Member Author

❌ 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 8 versions and merge any changes:

  • public/index.php
  • resources/lang/en/validation.php

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 streamlined the Exception Handler into a single register method to make it easier to add custom logic around rendering or reporting errors within your application.

While this change is not required, Shift recommends comparing yours against the Laravel 8.x version as an opportunity to reduce code and be fully up-to-date.

@ssddanbrown

Copy link
Copy Markdown
Member Author

❌ To match the other auth middleware, Laravel 8 now allows multiple guards for the RedirectIfAuthenticated middleware.

Shift attempted to automate these changes, but detected customizations. You will need to compare your app/Http/Middleware/RedirectIfAuthenticated.php with the default Laravel 8 version to finalize the upgrade.

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 introduced class based factories. Shift automated this change. However, if you were using a community package for factories or other custom code, you should review your factories for additional changes.

If you encounter an issue, you may revert this commit and temporarily install the laravel/legacy-factories package. You may then automate the conversion to class based factories using the Shift Workbench.

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 added a uuid column to the failed_jobs table to support the new job batching features.

Shift attempted to add this migration, but did not find the original migration for the failed_jobs table. If your application is using the failed_jobs table, you may generate a custom migration for this column by running:

php artisan make:migration AddUuidToFailedJobsTable

Then copy and paste the contents from Shift's AddUuidToFailedJobsTable class to add the uuid column and generate UUIDs for your existing failed jobs.

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 added new ENV variables for AWS_USE_PATH_STYLE_ENDPOINT, FILESYSTEM_DRIVER, and LOG_LEVEL. While these are defaulted within their respective configuration file, you may take this opportunity to set them accordingly for your environments.

@ssddanbrown

Copy link
Copy Markdown
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 08af910b and make the config file changes manually.

@ssddanbrown

Copy link
Copy Markdown
Member Author

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

Watch dealing with dependencies for tips on handling package incompatibilities.

@ssddanbrown

ssddanbrown commented Oct 28, 2021

Copy link
Copy Markdown
Member Author

⚠️ PHPUnit 8 deprecated using assertContains for strings. This assertion now only handles arrays or Traversable objects.

Shift attempted to convert assertions where possible, but detected additional uses of assertContains you should review and, if these arguments are strings, convert them to the new string assertion methods.

  • tests/Auth/Saml2Test.php

@ssddanbrown

Copy link
Copy Markdown
Member Author

⚠️ Laravel 8 now requires PHPUnit 9 which made some configuration changes to its config file. You may automate these changes by running vendor/bin/phpunit --migrate-configuration or comparing your phpunit.xml to the Laravel 8 version and merging any changes.

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 reintroduced the app/Models folder by default. This is an optional change. Laravel and the artisan commands will automatically detect if you are using the app/Models folder or not.

If you wish to modernize your application to use the app/Models folder, you may run the Namespace Models Shift for free.

@ssddanbrown

Copy link
Copy Markdown
Member Author

⚠️ The paginator now uses Tailwind for its default styling in Laravel 8. If you wish to continue using Bootstrap, you should add the following snippet to the boot method of your AppServiceProvider:

\Illuminate\Pagination\Paginator::useBootstrap();

@ssddanbrown

ssddanbrown commented Oct 28, 2021

Copy link
Copy Markdown
Member Author

⚠️ In Laravel 8, assertExactJson now requires numeric keys to match and be in the same order. If you would like to compare JSON without this requirement, you may use the assertSimilarJson method instead.

Shift found uses of assertExactJson in the following files:

  • tests/Entity/TagTest.php

@ssddanbrown

Copy link
Copy Markdown
Member Author

ℹ️ Laravel 8 supports running your PHPUnit tests in parallel. Depending on your system, this may decrease run times as much as 70%.

To run your tests in parallel, you may use the php artisan test --parallel command, or use the underlying vendor/bin/paratest runner.

@ssddanbrown

Copy link
Copy Markdown
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.

@ssddanbrown
ssddanbrown merged commit d83da84 into laravel_8_upgrade Oct 30, 2021
@ssddanbrown
ssddanbrown deleted the shift-51221 branch June 20, 2022 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants