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 and php 8.1 upgrade #344

Closed
wants to merge 15 commits into from
Closed

Laravel 10.x Shift and php 8.1 upgrade #344

wants to merge 15 commits into from

Conversation

omarrida
Copy link
Contributor

@omarrida omarrida commented Aug 8, 2024

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:

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

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 2024

ℹ️ 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
Copy link
Contributor Author

omarrida commented Aug 8, 2024

❌ 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.

  • tests/Feature/CollaboratorClaimTest.php
  • tests/Feature/CollaboratorCreateTest.php
  • tests/Feature/PackageCreateTest.php
  • tests/Feature/PackageCrudTest.php
  • tests/Feature/PackageEditTest.php

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 2024

ℹ️ 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
Copy link
Contributor Author

omarrida commented Aug 8, 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 3cb1a17e and make the config file changes manually.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 2024

ℹ️ 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
Copy link
Contributor Author

omarrida commented Aug 8, 2024

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

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 2024

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

  • app/Notifications/ApologizeForIncorrectGitHubDisconnect.php
  • app/Notifications/CollaboratorClaimed.php
  • app/Notifications/GithubAuthNotification.php
  • app/Notifications/NewPackage.php
  • app/Notifications/NotifyAuthorOfDisabledPackage.php
  • app/Notifications/NotifyAuthorOfUnavailablePackageUrl.php
  • app/Notifications/PackageDeleted.php
  • app/Notifications/RemindAuthorOfUnavailablePackage.php

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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 fac41c9 to revert the DocBlock changes.
  • git revert 4911f6b to revert the type hints added from DocBlocks.
  • git revert 0c76de2 to revert the type hints added for Laravel 10.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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/Package.php
  • app/RatingCountable.php

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 2024

⚠️ 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
Copy link
Contributor Author

omarrida commented Aug 8, 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.

@omarrida
Copy link
Contributor Author

omarrida commented Aug 8, 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/Jobs/SyncPackageRepositoryData.php
  • app/Listeners/ClaimOrCreateCollaboratorForNewUser.php

@omarrida omarrida changed the title Laravel 10.x Shift Laravel 10.x Shift and php 8.1 upgrade Aug 8, 2024
@omarrida omarrida requested a review from techenby August 8, 2024 20:04
Base automatically changed from develop to main August 12, 2024 14:57
@omarrida omarrida closed this Aug 12, 2024
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