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 #9

Open
wants to merge 10 commits into
base: shift-93023
Choose a base branch
from
Open

Laravel 10.x Shift #9

wants to merge 10 commits into from

Conversation

imagina
Copy link
Owner

@imagina imagina commented Jun 26, 2023

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

Before merging, you need to:

  • Checkout the shift-93939 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?, no CI?)

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.

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

ℹ️ Shift noticed you have additional namespaces in your application. You may use the Consolidate Namespaces Shift to simplify your namespaces into the default Laravel App namespace.

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

  • Modules/Iauctions/Rules/ValidatePath.php
  • Modules/Ihelpers/Rules/UniqueRule.php
  • Modules/Ihelpers/Rules/UniqueSlugRule.php
  • Modules/Iprofile/Rules/FieldsRule.php
  • Modules/Media/Validators/AlphaDashWithSpaces.php
  • Modules/Media/Validators/AvailableExtensionsRule.php
  • Modules/Media/Validators/MaxFolderSizeRule.php

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

ℹ️ 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 6444a240 to revert the DocBlock changes.
  • git revert aa413c64 to revert the type hints added from DocBlocks.
  • git revert 6ccc50e8 to revert the type hints added for Laravel 10.

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

⚠️ In previously versions of Laravel, stale cache tags would accumulate in the cache when using the Redis cache driver. Now to properly prune stale cache tag entries, Laravel 10 has a new Artisan command.

Shift detected calls to the Cache::tags() within your application. If you are using the Redis cache driver, you should schedule this command to run hourly:

$schedule->command('cache:prune-stale-tags')->hourly();

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

⚠️ In Laravel 10 you may no longer directly cast a DB:raw() expression to a string. Instead, you must retrieve the value from the expression using the getValue() method. Query builder methods will continue to handle DB::raw() expressions directly. This likely only affects instances where you are using DB::raw() expression 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.

  • Modules/Iad/Database/Migrations/2021_02_25_174612566163_create_iad_ads_table.php
  • Modules/Iad/Jobs/NotifyUploadAds.php
  • Modules/Iad/Jobs/UploadAds.php
  • Modules/Iad/Repositories/Eloquent/EloquentAdRepository.php
  • Modules/Iappointment/Services/AppointmentService.php
  • Modules/Iauctions/Jobs/CheckDaysToStartAuction.php
  • Modules/Iauctions/Jobs/CheckHoursToFinishAuction.php
  • Modules/Iblog/Repositories/Eloquent/EloquentPostRepository.php
  • Modules/Ibooking/Console/CheckStatusReservations.php
  • Modules/Ibooking/Jobs/CheckStatusReservations.php
  • Modules/Ichat/Events/Handlers/MessageWasSavedListener.php
  • Modules/Ichat/Repositories/Eloquent/EloquentConversationRepository.php
  • Modules/Ichat/Repositories/Eloquent/EloquentUserRepository.php
  • Modules/Icheckin/Repositories/Eloquent/EloquentApprovalRepository.php
  • Modules/Icommerce/Repositories/Eloquent/EloquentProductRepository.php
  • Modules/Icredit/Repositories/Eloquent/EloquentCreditRepository.php
  • Modules/Iplan/Jobs/NotifyExpiredSubscriptions.php
  • Modules/Iprofile/Repositories/Eloquent/EloquentUserApiRepository.php
  • Modules/Iwhmcs/Jobs/SetClientToInvoices.php
  • Modules/Iwhmcs/Jobs/SyncClientsToBitrix24.php
  • Modules/Iwhmcs/Jobs/syncDueInvoicesItemsToBitrix.php
  • Modules/Iwhmcs/Jobs/syncInvoicesByContactToBitrix.php
  • Modules/Iwhmcs/Jobs/syncProductsToBitrix.php

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

ℹ️ 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. You should review the Symfony change log for any additional changes.

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

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

Next, you may optionally run the following Shifts to ensure your application is fully upgraded, adopts the latest Laravel conventions, and easier to maintain in the future:

  • Upgrade Checker ensures your application is fully upgraded by detecting any outdated code.
  • Laravel Fixer automatically updates your code to the latest Laravel conventions.
  • Tests Generator intelligently generates model factories, HTTP Tests, and configuration for your application.
  • CI Generator intelligently generates CI jobs to lint PHP, check code style, and run tests, including Dusk.

You may also use the Shift Workbench to automate common tasks for maintaining your Laravel and PHP applications.

@imagina
Copy link
Owner Author

imagina commented Jun 26, 2023

❌ PHP syntax errors were detected after running your Shift. Often these are simply differences between the PHP version on the Shift server (8.1) 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:

  • Modules/Core/Icrud/Routing/RouterGenerator.php
  • Modules/Dashboard/Repositories/Eloquent/EloquentWidgetRepository.php
  • Modules/Ibanners/Repositories/Cache/CacheBannerDecorator.php
  • Modules/Ibanners/Repositories/Cache/CachePositionDecorator.php
  • Modules/Ibuilder/View/Components/Block.php
  • Modules/Ilocations/Repositories/Cache/CacheNeighborhoodDecorator.php
  • Modules/Iplan/Http/Controllers/Api/SubscriptionController.php
  • Modules/Media/Image/Imagy.php
  • Modules/Notification/Repositories/Cache/CacheNotificationDecorator.php
  • Modules/Translation/Repositories/Cache/CacheTranslationDecorator.php
  • app/Overrides/LaravelLocalization.php

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