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 10.x Shift #2230

Merged
merged 30 commits into from
Aug 8, 2024
Merged

Laravel 10.x Shift #2230

merged 30 commits into from
Aug 8, 2024

Conversation

alainvd
Copy link
Collaborator

@alainvd alainvd commented Apr 23, 2024

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

Before merging, you need to:

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

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

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
Accessing Faker properties was deprecated in Faker 1.14.
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
@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

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

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Laravel 10 deprecated the ImplicitRule, InvokableRule, and Rule contracts in favor of using the new, streamlined ValidationRule contract. These contracts will be removed in a future version of Laravel.

Given the change in the method names and return type, Shift can not reliably automate this change. At your convenience, you should review these custom validation rules and update them to implement the ValidationRule contract.

  • app/Rules/validAudience.php
  • app/Rules/validTheme.php

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

⚠️ 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 75c15ff6 and make the config file changes manually.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Laravel 10 now verifies hashed values were created by the same hashing algorithm. If your application has hashed values created by different hashing algorithms, you may set the verify option to false in your hashing configuration. For more details, you may review the original PR.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

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

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

⚠️ Sanctum 3.x added an expires_at column to support expiring tokens. Although Shift detected a dependency for laravel/sanctum, it did not find the migration for the personal_access_tokens table.

If your application is using the personal_access_tokens table, you may generate a custom migration for this column by running:

php artisan make:migration AddExpiresAtToPersonalAccessTokensTable

Then copy and paste the contents from Shift's migration to add the expires_at column to your existing personal_access_tokens table.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Shift detected your application has a test suite. To allow your to verify the upgrade in isolation, Shift did not bump your testing dependencies for PHPUnit 10. Once you have completed your upgrade, you may run the PHPUnit 10 Shift for free to upgrade your test suite to PHPUnit 10 separately.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

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

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Laravel renamed the password_resets table to password_reset_tokens. While an optional change, Shift detected you have a migration for the original table and created a migration to rename the table. You should check for any additional references to the password_resets table and run php artisan migrate to complete your upgrade.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Laravel 10 added PHP type hints to all user-land code included in a new Laravel application. In an effort to modernize your code, Shift added type hints to any method which is used by Laravel.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Now with type hints in your code, defining types within PHP DocBlocks is redundant. Laravel has removed all of the @param and @return tags from its DocBlocks where types are defined with PHP. Similarly, Shift removed these tags from any DocBlock where the code now has equivalent type hints.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Shift understands developers have different preferences when it comes to type hints. All of Shift's automation is done in nice, atomic commits. This makes it easier to undo any of the changes Shift makes.

If you wish to undo the changes relating to type hints, you may run:

  • git revert 221e8d0 to revert the DocBlock changes.
  • git revert 12ccf72 to revert the type hints added from DocBlocks.
  • git revert 0253335 to revert the type hints added for Laravel 10.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

⚠️ In Laravel 10 you may no longer implicitly cast a DB::raw() expression to a string. Instead, you must retrieve the string value from the expression using the getValue() method. Query builder methods will continue to automatically handle DB::raw() expressions as before. This change only affects instances where you are using DB::raw() expressions in your own code.

Shift detected calls to DB::raw(). You should review these instances to see if you are attempting to use them as a string.

  • app/Console/Commands/LoadAmbassadors.php
  • app/Console/Commands/LoadCountries.php
  • app/Console/Commands/LoadTags.php
  • app/Console/Commands/RemindCreators.php
  • app/Country.php
  • app/Helpers/AmbassadorHelper.php
  • app/Helpers/Codeweek4AllHelper.php
  • app/Helpers/ExcellenceWinnersHelper.php
  • app/Helpers/TagsHelper.php
  • app/Http/Controllers/ScoreboardController.php
  • app/Http/Controllers/UserController.php
  • app/Queries/CountriesQuery.php
  • app/Queries/SuperOrganiserQuery.php

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ All of the underlying Symfony components used by Laravel have been upgraded to Symfony 6.2. 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.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ The app/Models folder was reintroduced in Laravel 8. This was 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.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

ℹ️ Laravel began using Vite to build frontend assets in Laravel 9.19. While you may continue to use Laravel Mix, it is no longer the default. If you wish to modernize your application to use Vite, you may run the Vite Converter for free.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

⚠️ Laravel 10 requires Composer 2.2 or higher. You should verify the Composer version in your environments by running composer --version to ensure it meets this new requirement. If necessary, run composer self-update to update Composer.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 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.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 23, 2024

❌ PHP syntax errors were detected after running your Shift. Often these are simply differences between the PHP version on the Shift server (8.2) and your project. Occasionally they are misplaced lines or duplicate import statements.

You may quickly check the PHP syntax locally by running php -l on the following files:

  • app/Filters/EventFilters.php
  • app/Filters/ResourceFilters.php
  • config/services.php
  • routes/web.php

@alainvd alainvd merged commit 98dfcd3 into master Aug 8, 2024
1 check passed
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