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 6.x Shift #7688

Closed
wants to merge 13 commits into from
Closed

Laravel 6.x Shift #7688

wants to merge 13 commits into from

Conversation

bhanu2217
Copy link
Contributor

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

Before merging, you need to:

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

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).
Laravel 5.2 no longer registers the `Input` facade by default. While
still available in Laravel 5, the `Input` facade is removed in
Laravel 6.
@bhanu2217
Copy link
Contributor Author

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

@bhanu2217
Copy link
Contributor Author

❌ Shift could not upgrade the following files since they differed from the default Laravel version. You will need to compare these files against the default Laravel 6 versions and merge any changes:

  • app/Http/Controllers/Auth/ForgotPasswordController.php
  • app/Http/Controllers/Auth/ResetPasswordController.php
  • app/Http/Kernel.php
  • resources/lang/en/passwords.php

@bhanu2217
Copy link
Contributor Author

⚠️ Laravel 6.x consolidated references to /home as a constant within the RouteServiceProvider. This makes it easier to maintain and change in a single place.

Shift automated this change, but could not upgrade the following files since they differed from the default Laravel version. You should compare these files against the default Laravel 6 versions and merge this change:

  • app/Http/Controllers/Auth/LoginController.php
  • app/Http/Middleware/RedirectIfAuthenticated.php

@bhanu2217
Copy link
Contributor Author

ℹ️ Laravel 6 changed the default Redis client from predis to phpredis. You may keep using predis by setting REDIS_CLIENT=predis for your environment.

@bhanu2217
Copy link
Contributor Author

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

@bhanu2217
Copy link
Contributor Author

⚠️ In Laravel 6, the update method of the BelongsTo relationship no longer provides mass assignment protection or fires Eloquent events. If you wish to preserve this behavior, you should call update on the model itself.

// no mass assignment protection or events...
$post->user()->update(['foo' => 'bar']);

// mass assignment protection and events...
$post->user->update(['foo' => 'bar']);

Shift found potential uses of the update method in:

  • app/Console/Commands/SetupTestEnv.php

@bhanu2217
Copy link
Contributor Author

ℹ️ The Eloquent model's toArray() method will now cast any attributes that implement Illuminate\Contracts\Support\Arrayable to an array. While unlikely to impact your application, this change could effect code which relies upon the previous data type or output.

@bhanu2217
Copy link
Contributor Author

⚠️ Starting in Laravel 5.2, the Input facade is no longer registered by default. Although the Input facade is still available in Laravel 5, it is removed in Laravel 6. As such, Shift recommends using the Request facade or the injected $request object within Controllers and Middleware.

Shift updated your application to use the Request facade and recommends using the Laravel Fixer to automate converting your code to use the injected $request object where available.

@bhanu2217
Copy link
Contributor Author

⚠️ You should run php artisan view:clear to avoid Blade errors related to the methods changed within the Lang Facade.

@bhanu2217
Copy link
Contributor Author

ℹ️ Laravel 6 now requires Carbon 2. While Shift reviewed your application for common breaking changes, you may want to review the Carbon 2 migration notes for additional changes.

@bhanu2217
Copy link
Contributor Author

ℹ️ Laravel 6 made some changes to the email verification routes. First, to prevent CSRF attacks the email/resend has been changed from a GET to a POST route. Second, a hash parameter was added to the email/verify route.

If you were calling these routes in your application code, you will need to adjust the requests accordingly.

@bhanu2217
Copy link
Contributor Author

⚠️ Previous versions of Laravel would bind parameters passed to the URL helper methods as placeholder values even if the names mismatched. In Laravel 6, named parameters not matching placeholders are attached to the query string instead.

Shift detected the following route() and action() calls passing named parameters you should review to ensure they match the route placeholder name.

  • app/Model/helpdesk/Ticket/Ticket_attachments.php
  • resources/views/themes/default1/client/helpdesk/ckeckticket.blade.php
  • resources/views/themes/default1/client/helpdesk/ckeckticket2.blade.php
  • resources/views/themes/default1/client/helpdesk/ckeckticketOld.blade.php
  • resources/views/themes/default1/client/helpdesk/guest-user/view_ticket.blade.php
  • resources/views/themes/default1/client/helpdesk/ticket.blade.php
  • resources/views/themes/default1/client/helpdesk/unauth/showticket.blade.php

@bhanu2217
Copy link
Contributor Author

⚠️ The elixir helper was deprecated in Laravel 6.0 and removed in Laravel 8.0. You are are encouraged to upgrade to Laravel Mix or another build tool.

Shift found potential uses of the elixir helper in the following files:

  • ./gulpfile.js
  • ./vendor/laravel/framework/src/Illuminate/Foundation/helpers.php

@bhanu2217
Copy link
Contributor Author

ℹ️ Laravel 6 made performance optimizations for integer key types. If you are using a string as your model's primary key, you may set the $keyType property on your model.

/**
 * The "type" of the primary key ID.
 *
 * @var string
 */
protected $keyType = 'string';

@bhanu2217
Copy link
Contributor Author

ℹ️ The mandrill and sparkpost mail drivers, as well as the rackspace storage driver were removed in Laravel 6. If you were using these drivers, you may adopt a community maintained package which provides the driver.

@bhanu2217
Copy link
Contributor Author

ℹ️ Previous versions of Laravel would retry jobs indefinitely. Beginning with Laravel 6, the php artisan queue:work now tries a job one time by default. If you want to force jobs to be tried indefinitely, you may pass the --tries=0 option.

@bhanu2217
Copy link
Contributor Author

⚠️ Laravel 6.x has reached end of life. It no longer receives bug fixes. Shift recommends continuing to upgrade to the latest version (Laravel 9.x).

For tips on running multiple Shifts effectively, watch upgrading old Laravel applications.

@bhanu2217 bhanu2217 added this to the v2.0.0 milestone Jan 7, 2023
@RafficMohammed RafficMohammed deleted the shift-77532 branch March 1, 2023 05:53
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.

4 participants