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 8.x Shift #199

Merged
merged 27 commits into from May 26, 2021
Merged

Laravel 8.x Shift #199

merged 27 commits into from May 26, 2021

Conversation

mattstauffer
Copy link
Member

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

Before merging, you need to:

  • Checkout the shift-44295 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?)

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 your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
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.
@mattstauffer
Copy link
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.

@mattstauffer
Copy link
Member Author

ℹ️ The RouteServiceProvider no longer prefixes the controller namespace by default in Laravel 8. While you may still set the $namespace property, you are encouraged to register your routes using static ::class references.

You may automate the conversion to static class references by running the Class Based Routes task within Shift Workbench or running the Laravel Fixer.

@mattstauffer
Copy link
Member Author

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

If your application is currently using the failed_jobs table, you may generate a custom migration for this command 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.

@mattstauffer
Copy link
Member Author

ℹ️ Laravel 8 added a new ENV variable of LOG_LEVEL. While the log level is defaulted in the configuration, you may take this opportunity to set it accordingly in your environments.

@mattstauffer
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 5b91aa0b and make the config file changes manually.

@mattstauffer
Copy link
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.

@mattstauffer
Copy link
Member Author

❌ Shift detected Vue components within your resources folder. Laravel Mix 6 extracted Vue support into its own feature flag.

You should update your webpack.mix.js and append the new mix.vue() call when building any Vue components. For example:

mix.js('resources/js/app.js', 'public/js').vue();

@mattstauffer
Copy link
Member Author

⚠️ Shift upgraded your NPM dependencies and scripts for Laravel Mix 6. You will need to run npm install locally to ensure your dependencies are up-to-date and compatible.

If you encounter any issues, be sure you have the latest LTS or stable version of Node installed. If the problem persists, review the Update to Mix 6 docs for any additional steps.

@mattstauffer
Copy link
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.

@mattstauffer
Copy link
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.

@mattstauffer
Copy link
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.

@mattstauffer
Copy link
Member Author

🎉 Congratulations, you're now running the latest version of Laravel.

The following Shifts may be used ensure your application is fully upgraded and easier to maintain in the future:

  • Upgrade Checker ensures your application is fully upgraded by detecting any outdated code.
  • Laravel Fixer automates many of the suggestions found by the Laravel Linter and other Shifts.
  • Tests Generator intelligently generates model factories, HTTP Tests, and unit tests for your application to give you a head start on testing.

You may run these Shifts and stay upgraded forever as well by subscribing to a Shifty Plans.

@allenjd3
Copy link
Contributor

So I was reading up on moving the models to a models directory and it seems pretty much like you just need to move it and change the namespace. Do you know if the CI will handle the dump-autoload command?

@mattstauffer
Copy link
Member Author

Yep, because the CI runs composer install and that triggers a dump auto load :)

@mattstauffer mattstauffer merged commit 397a139 into main May 26, 2021
@mattstauffer mattstauffer deleted the shift-44295 branch May 26, 2021 01:09
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.

None yet

3 participants