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

Merged
merged 12 commits into from Oct 26, 2021
Merged

Laravel 7.x Shift #3011

merged 12 commits into from Oct 26, 2021

Conversation

@ssddanbrown
Copy link
Member

@ssddanbrown ssddanbrown commented Oct 26, 2021

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

Before merging, you need to:

  • Checkout the shift-51217 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?)

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.

laravel-shift added 10 commits Oct 26, 2021
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] config to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started.

For more information on customizing the code style applied by Shift, [watch this short video][4].

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://github.com/squizlabs/PHP_CodeSniffer
[3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
[4]: https://laravelshift.com/videos/shift-code-style
PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.
@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ Shift detected a custom namespace. Laravel now recommends keeping the default App namespace. While it was available to customize in previous versions using app:name, this command was removed in Laravel 6.

Shift recommends changing this to align with Laravel and improve its automation. After doing so, you are welcome to request a rerun of this Shift.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ Laravel 7 adds CORS middleware and defaults the middlewarePriority internally so you only need to overwrite this property for customizations.

Shift attempted to automate these changes. But you should compare your app/Http/Kernel.php with the default Laravel 7 version to finalize any changes.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

ℹ️ Laravel 7 upgraded to Symfony 5 which passes instances of the Throwable interface instead of Exception instances to core components like the Exceptions\Handler.

Shift automated this change. However, if you receive a Throwable type mismatch error there may be additional references you need to convert.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

ℹ️ Laravel 7 moved the Authentication components into a separate laravel/ui package, which includes the make commands as well as the traits related to authentication.

Shift added this dependency for convenience. However, if you do not plan to use the Authentication components, you may remove this dependency as well as the Auth controllers from your application.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

ℹ️ Laravel 7 renamed usages of the Eloquent addVisible and addHidden methods to makeVisible and makeHidden respectively.

Shift automated this change. However, you should review these changes as well as check your application for any additional instances.

  • app/Http/Controllers/PageController.php

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ The MAIL_DRIVER environment variable was renamed in Laravel 7 to MAIL_MAILER in order to support multiple mail configurations.

Shift attempted to automate this change, but you should review any additional environment configuration and update to the new variable name.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

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

Watch dealing with dependencies for tips on handling package incompatibilities.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

ℹ️ Laravel 7 removed some of the PHPUnit configuration in favor of the defaults. While this is not a required changed, it is a good opportunity to compare your phpunit.xml with the default Laravel 7 version to modernize your configuration.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ In Laravel 7, all of the assertSee methods now automatically escape the expected values.

If you were manually escaping the values passed to these methods, you no longer need do so. If you were asserting values containing HTML that should not be escaped, you may set the new escaped argument to false.

Shift found the instances of these assertions within:

  • tests/Api/ApiDocsTest.php
  • tests/Api/BooksApiTest.php
  • tests/Api/ChaptersApiTest.php
  • tests/Api/PagesApiTest.php
  • tests/AuditLogTest.php
  • tests/Auth/AuthTest.php
  • tests/Auth/LdapTest.php
  • tests/Auth/MfaConfigurationTest.php
  • tests/Auth/MfaVerificationTest.php
  • tests/Auth/OidcTest.php
  • tests/Auth/Saml2Test.php
  • tests/Auth/SocialAuthTest.php
  • tests/Auth/UserInviteTest.php
  • tests/DebugViewTest.php
  • tests/Entity/BookShelfTest.php
  • tests/Entity/BookTest.php
  • tests/Entity/ChapterTest.php
  • tests/Entity/CommentTest.php
  • tests/Entity/EntityAccessTest.php
  • tests/Entity/EntitySearchTest.php
  • tests/Entity/ExportTest.php
  • tests/Entity/PageContentTest.php
  • tests/Entity/PageDraftTest.php
  • tests/Entity/PageRevisionTest.php
  • tests/Entity/PageTemplateTest.php
  • tests/Entity/PageTest.php
  • tests/Entity/SortTest.php
  • tests/Entity/TagTest.php
  • tests/ErrorTest.php
  • tests/FavouriteTest.php
  • tests/HomepageTest.php
  • tests/LanguageTest.php
  • tests/Permissions/EntityPermissionsTest.php
  • tests/Permissions/ExportPermissionsTest.php
  • tests/Permissions/RolesTest.php
  • tests/PublicActionTest.php
  • tests/RecycleBinTest.php
  • tests/SecurityHeaderTest.php
  • tests/Settings/CustomHeadContentTest.php
  • tests/Settings/FooterLinksTest.php
  • tests/ThemeTest.php
  • tests/Unit/UrlTest.php
  • tests/Uploads/AttachmentTest.php
  • tests/Uploads/DrawioTest.php
  • tests/Uploads/ImageTest.php
  • tests/User/UserApiTokenTest.php
  • tests/User/UserManagementTest.php
  • tests/User/UserPreferencesTest.php
  • tests/User/UserProfileTest.php

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ Shift found potential uses of the different validation rule. In Laravel 7, this rule will fail if one of the specified parameters is missing from the request. As this was likely the expected behavior, it should not affect your validation. Nonetheless you should be aware of this change.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ Laravel 7 uses a new date format when serializing models. The previous format was 2019-12-02 20:01:00. Now, dates are serialized using an ISO-8601 compatible date format of 2019-12-02T20:01:00.283041Z in UTC.

This does not affect how dates are stored. Only how they are serialized when using the toArray or toJson Eloquent methods.

If you need to preserve the previous format, you may override the serializeDate method on your model. Review the Date Serialization section of the Upgrade Guide for more details.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

ℹ️ All of the underlying Symfony components used by Laravel have been upgraded to Symfony 5. If you are directly interacting with any Symfony component, you should review the Symfony change log for additional changes.

@ssddanbrown
Copy link
Member Author

@ssddanbrown ssddanbrown commented Oct 26, 2021

⚠️ Laravel 7.x has reached end of life. It no longer receives bug fixes or security updates. Shift recommends continuing to upgrade to the latest stable version (Laravel 8.x).

@ssddanbrown ssddanbrown added this to the Next Feature Release milestone Oct 26, 2021
@ssddanbrown ssddanbrown self-assigned this Oct 26, 2021
@ssddanbrown ssddanbrown merged commit f77236a into laravel_upgrade Oct 26, 2021
2 of 14 checks passed
@ssddanbrown ssddanbrown deleted the shift-51217 branch Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants