tighten / novapackages

https://novapackages.com
335 stars 61 forks source link

Laravel 10.x Shift and php 8.1 upgrade #344

Closed omarrida closed 1 month ago

omarrida commented 1 month ago

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

Before merging, you need to:

If you need help with your upgrade, check out the Human Shifts.

omarrida commented 1 month ago

:information_source: Starting with Laravel 10, the lang folder 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 config:publish --all --force to get the latest configuration files from Laravel 11, then reapplying the customizations Shift streamlined.

omarrida commented 1 month ago

:x: The deprecated MocksApplicationServices trait has been removed in Laravel 10 and, as a result, the WithoutEvents trait is no longer supported and will be removed in Laravel 11. These traits provided testing methods such as expectsEvents, expectsJobs, and expectsNotifications.

Shift found potential references to these methods and traits in the following files. You will need to refactor this code to use Event, Bus, or Notification fakes.

omarrida commented 1 month ago

:information_source: Laravel 10 increased the hashing cost from 10 to 12. However, the hashing cost defaults to 4 when testing. To ensure the lower hashing cost is respected when running testing, the default UserFactory now hashes the password instead of hardcoding the hashed value.

You should review your UserFactory and any other factory that may hardcode a hashed value. For more details, you may reference the original PR changes.

omarrida commented 1 month ago

:warning: 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 3cb1a17e and make the config file changes manually.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

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

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:warning: Laravel 10 has added a return type of array to the Event broadcastOn and Notification via methods. However, you may still return a single channel from these methods.

Shift added the array return type to these methods in the following classes. You should review them to ensure you are returning an array, or remove the return type.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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:

omarrida commented 1 month ago

:warning: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:information_source: 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.

omarrida commented 1 month ago

:warning: 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.

omarrida commented 1 month ago

:warning: Laravel 10 requires PHP 8.1 or higher. You should verify the PHP version in your environments to ensure it meets this new requirement.

omarrida commented 1 month ago

:warning: 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.

omarrida commented 1 month ago

:x: 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: