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.0 Shift #470

Merged
merged 9 commits into from
Sep 30, 2019
Merged

Laravel 6.0 Shift #470

merged 9 commits into from
Sep 30, 2019

Conversation

viralsolani
Copy link
Collaborator

This pull request includes the changes for upgrading to Laravel 6.0. Feel free to commit any additional changes to the shift-19113 branch.

Before merging, you need to:

  • Checkout the shift-19113 branch
  • Review all pull request comments for additional changes
  • Update your dependencies for Laravel 6.0
  • Run composer update (if the scripts fail, add --no-scripts)
  • Thoroughly test your application (no tests?)

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.

The Laravel framework adopts the PSR-2 coding style with some additions.
Laravel apps *should* adopt this coding style as well.

However, Shift allows you to customize the adopted coding style through
by using your [PHP CS Fixer][1] config within your project.

You may use [Shift's .php_cs][2] file as a base.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
Laravel recommends using the `Str` and `Arr` class methods directly instead of the respective helper functions. These helper functions are [deprecated in Laravel 5.8][1] and will be removed in a future version.

[1]: laravel/framework#26898
In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them so you can review the commit diff for
changes. Moving forward, you should use ENV variables or create a
separate config file to allow the core config files to remain
automatically upgradeable.
From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html
@viralsolani
Copy link
Collaborator Author

❌ Shift could not upgrade your HTTP Kernel because it differed from the default version. You will need to compare this file against the default Laravel 6.0 version and merge any changes.

@viralsolani
Copy link
Collaborator Author

⚠️ Shift defaulted the following configuration files. This was done in the Default config files commit so you may easily review and backfill your customizations. If you have a lot of customizations, you may also undo this commit with git revert and upgrade these files manually.

  • config/database.php
  • config/mail.php
  • config/services.php

@viralsolani
Copy link
Collaborator Author

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

However, if possible, consider switching to phpredis to gain the performance of its PHP extension and avoid using the deprecated predis dependency which will be removed in Laravel 7.0.

@viralsolani
Copy link
Collaborator Author

ℹ️ Shift makes an effort to update your dependencies for Laravel 6.0. While many of the popular packages are reviewed, you may have to update additional packages or version constraints in order for your application to be compatible with Laravel 6.0. Watch dealing with dependencies for tips on handling package incompatibilities.

@viralsolani
Copy link
Collaborator Author

⚠️ In Laravel 6.0, 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/Repositories/Frontend/Access/User/UserRepository.php

@viralsolani
Copy link
Collaborator 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.

@viralsolani
Copy link
Collaborator Author

⚠️ Previous versions of Laravel would use parameters passed to the route() helper as URI values even if the parameter had no matching placeholder within the route path. In Laravel 6.0, values not matching placeholders are attached to the query string instead.

Shift detected the following uses of the route() helper you should review to ensure the route parameter key and route placeholder name match.

  • app/Helpers/helpers.php
  • app/Http/Breadcrumbs/Backend/Access/Permission.php
  • app/Http/Breadcrumbs/Backend/Access/Role.php
  • app/Http/Breadcrumbs/Backend/Access/User.php
  • app/Http/Breadcrumbs/Backend/Blog.php
  • app/Http/Breadcrumbs/Backend/Blog_Category.php
  • app/Http/Breadcrumbs/Backend/Blog_Management.php
  • app/Http/Breadcrumbs/Backend/Blog_Tag.php
  • app/Http/Breadcrumbs/Backend/Faqs.php
  • app/Http/Breadcrumbs/Backend/Menu.php
  • app/Http/Breadcrumbs/Backend/Page.php
  • app/Http/Breadcrumbs/Backend/Setting.php
  • app/Http/Controllers/Backend/Access/User/UserPasswordController.php
  • app/Http/Controllers/Backend/Settings/SettingsController.php
  • app/Models/Access/Role/Traits/Attribute/RoleAttribute.php
  • app/Models/Access/User/Traits/Attribute/UserAttribute.php
  • app/Models/Faqs/Traits/Attribute/FaqAttribute.php
  • app/Models/ModelTrait.php
  • app/Models/Page/Traits/Attribute/PageAttribute.php
  • app/Notifications/Frontend/Auth/UserNeedsConfirmation.php
  • app/Notifications/Frontend/Auth/UserNeedsPasswordReset.php
  • resources/lang/en/exceptions.php

@viralsolani
Copy link
Collaborator Author

ℹ️ Laravel 6.0 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';

@viralsolani
Copy link
Collaborator Author

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

@viralsolani
Copy link
Collaborator Author

ℹ️ Previous versions of Laravel would retry jobs indefinitely. Beginning with Laravel 6.0, 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.

@viralsolani
Copy link
Collaborator Author

ℹ️ Shift detected you are using a Laravel package which has its own assets or views which may need to be regenerated after upgrading. Be sure to use artisan to publish these as well as php artisan view:clear to avoid any errors.

@viralsolani
Copy link
Collaborator Author

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

The following Shifts can ensure your app is fully upgraded and following the practices recommended by Laravel and the community:

  • Laravel Linter analyzes your codebase for potential opportunities to do things "The Laravel Way".
  • Laravel Fixer automates many of the suggestions found by the Linter and other Shifts.
  • Upgrade Checker ensures your application is fully upgraded by detecting any outdated code.

In addition, stay upgraded forever as well as run these Shifts by subscribing to one of the new Shifty Plans.

@viralsolani viralsolani merged commit b5d7f55 into laravel_6.0 Sep 30, 2019
@viralsolani viralsolani deleted the shift-19113 branch November 27, 2019 11:09
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