-
Notifications
You must be signed in to change notification settings - Fork 6
Maintenance: Upgrade to Laravel 10 #806
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
base: develop
Are you sure you want to change the base?
Conversation
Since PHP 5.4 the short array syntax `[]` may be used instead of `array()`.
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.
In Laravel 10 you may no longer implicitly cast a `DB::raw()` expression to a string, so we need to update all the code to drop the `DB::raw()` calls.
…ract - Replace deprecated Rule interface with new ValidationRule contract - Refactor validation logic to use new validate method with callback - Mark unused $attribute parameter with underscore prefix The Timezone rule class is imported in GroupController.php and EventController.php but not used directly so there are no references we need to update. Part of Laravel 10 upgrade process
Part of the Laravel 10 upgrade process.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarCloud found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
Somethings to note:
|
|
@ardelato Just to let you know I'm going to sort out the move to vite. |




Description
Most of the changes were automatically created by
Laravel Shift. There were some additional tweaks that needed to be made in order to get things working.Note
The referenced commits/links may not be correct as I had to rebase and use the commits from -- iFixit#2
Shift Output
This pull request includes the changes for upgrading to Laravel 10.x.
Before merging, you need to:
composer update(if the scripts fail, try with--no-scripts)If you need help with your upgrade, check out the Human Shifts.
langfolder is no longer included in a default Laravel application. Laravel now recursively merges any customizations with framework defaults.Shift streamlined your language files by removing options that matched the Laravel defaults and preserving your customizations. If you wish to keep the full set of language, Shift recommends running
artisan lang:publish --forceto get the latest configuration files from Laravel, then reapplying the customizations Shift streamlined.ImplicitRule,InvokableRule, andRulecontracts in favor of using the new, streamlinedValidationRulecontract. 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
ValidationRulecontract.lang/en.jsonfile containing password validation messages. However, this file was quickly removed in favor of keeping this with the other validation rules invalidation.php.Shift detected your version differed from the default Laravel version. If you have customized the password validation messages, you should merge them with the
passwordmessages invalidation.phpand removelang/en.json.ENVvariables.You should review this commit for additional customizations or opportunities to use new
ENVvariables. If you have a lot of customizations, you may undo this commit withgit revert 422343d4and make the config file changes manually.ℹ️ 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
verifyoption tofalsein your hashing configuration. For more details, you may review the original PR.ℹ️ 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.
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.
ℹ️ Shift detected your application has a test suite. To allow you 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.
ℹ️ Laravel 9 adopted anonymous migrations. Shift automated this change to align with modern Laravel conventions and avoid naming migrations.
ℹ️ Laravel renamed the
password_resetstable topassword_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 thepassword_resetstable and runphp artisan migrateto complete your upgrade.arrayto the EventbroadcastOnand Notificationviamethods. However, you may still return a single channel from these methods.Shift added the
arrayreturn type to these methods in the following classes. You should review them to ensure you are returning anarray, or remove the return type.ℹ️ 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.
ℹ️ Now with type hints in your code, defining types within PHP DocBlocks is redundant. Laravel has removed all of the
@paramand@returntags 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.ℹ️ 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 eb6605d9cdto revert the DocBlock changes.git revert cc190c3a99to revert the type hints added from DocBlocks.git revert bf39c4a7ebto revert the type hints added for Laravel 10.DB::raw()expression to a string. Instead, you must retrieve the string value from the expression using thegetValue()method. Query builder methods will continue to automatically handleDB::raw()expressions as before. This change only affects instances where you are usingDB::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.ℹ️ 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.
ℹ️ The
app/Modelsfolder was reintroduced in Laravel 8. This was an optional change. Laravel and theartisancommands will automatically detect if you are using theapp/Modelsfolder or not.If you wish to modernize your application to use the
app/Modelsfolder, you may run the Namespace Models Shift for free.ℹ️ 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.
composer --versionto ensure it meets this new requirement. If necessary, runcomposer self-updateto update Composer.CR Notes
Outside of the Laravel Shift changes, I tried to explain the reasoning for each change in the commit messages.
All the changes are related to the action items described in the Shift output. I condensed the action items into a list and added notes to provide additional context on some of the changes.
Laravel Shift Action Items
Laravel 10 Upgrade Action Items
Validation Rules
app/Rules/Timezone.phpto implement the newValidationRulecontract instead of the deprecated contractsPassword Validation
lang/en.jsonintovalidation.phplang/en.jsonafter merginglang/en.jsonbut we do have anauth.phpfile that only has a single message for mismatched and less than 6 character password failure message.Hashing Configuration
verifyoption tofalsein hashing config if neededEvent & Notification Return Types
Fix
arrayreturn type in the following files:app/Events/EventDeleted.phpapp/Events/UserEmailUpdated.phpapp/Events/UserLanguageUpdated.phpapp/Events/UserRegistered.phpapp/Notifications/BaseNotification.phpapp/Notifications/EventConfirmed.phpapp/Notifications/EventDevices.phpapp/Notifications/GroupConfirmed.phpapp/Notifications/JoinEvent.phpapp/Notifications/JoinGroup.phpapp/Notifications/ResetPassword.phpbroadcastOn()method instead of an array. We updated them to return arrays.via()methods.DB::raw() Usage Fixes
Replace
DB::statement(DB::raw('query'))withDB::statement('query')andDB::select(DB::raw('query'))withDB::select('query').For direct string uses of DB::raw, add
->getValue()method.database/migrations/2020_10_21_121813_alter_table_charsets.phpdatabase/migrations/2021_08_13_000439_update_lca_unpowered_categories.phpdatabase/migrations/2022_01_24_101405_timezones.phpdatabase/migrations/2022_11_07_152558_record_approval.phpdatabase/migrations/2023_06_07_130653_new_zealand.phpdatabase/migrations/2023_06_12_153317_country_codes.phpdatabase/migrations/2023_08_02_183803_item_type_collation.phptests/Feature/Networks/APIv2NetworkTest.phptests/Feature/Events/ModerationEventPhotosNotificationTest.phpapp/Category.phpapp/Console/Commands/FixViews.phpapp/Device.phpapp/Group.phpapp/Helpers/Fixometer.phpapp/Helpers/FixometerFile.phpapp/Helpers/LcaStats.phpapp/Party.phpapp/Role.phpapp/Session.phpapp/User.phpapp/UserGroups.phpapp/Xref.phptests/Feature/Groups/GroupEditTest.phpDependencies
wouternl/laravel-drippackagephp-coverallspackageDatabase Migrations
php artisan migrateto complete table renamingEnvironment Requirements
Notes
DB::statement(DB::raw('query'))→DB::statement('query')DB::select(DB::raw('query'))→DB::select('query')'SELECT * FROM'.$table.''with"SELECT * FROM{$table}"DB::raw, add->getValue():$someVar = DB::raw('EXPRESSION')->getValue()Some additional things to note, I did not address item
16and17in this pull, but I will do so in a follow up pull.