Skip to content

Laravel 5.2 Shift#1

Open
uilll wants to merge 14 commits into
mainfrom
shift-92600
Open

Laravel 5.2 Shift#1
uilll wants to merge 14 commits into
mainfrom
shift-92600

Conversation

@uilll

@uilll uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner

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

Before merging, you need to:

  • Checkout the shift-92600 branch
  • Review all pull request comments for additional changes
  • Update your dependencies for Laravel 5.2
  • Run composer update (if the scripts fail, add --no-scripts)
  • 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).
Since PHP 5.4 the short array syntax `[]` may be used instead of `array()`.
Jobs are self handling by default in Laravel 5.2.
Laravel 5.2 adjusts the `Guard` object used within middleware. In
addition, new `can` and `throttles` middleware were added.
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.
In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.
PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner 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.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ Laravel 5.2 modified the default Middleware. Since your middleware differs from the Laravel 5.1 default, you will need to compare the following middleware against the 5.2 versions and merge any changes.

  • app/Http/Middleware/Authenticate.php
  • app/Http/Middleware/RedirectIfAuthenticated.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ Laravel 5.2 separates web and API functionality into Middleware Groups. Shift was unable to automate all of these changes. You will need to compare the following files against their 5.2 versions and merge any changes manually.

  • app/Http/Kernel.php
  • app/Providers/RouteServiceProvider.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ The Authentication configuration changed significantly in Laravel 5.2. Since your config/auth.php differs from the Laravel 5.1 default, you will need to compare yours against the 5.2 version and merge any changes.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

ℹ️ Laravel 5.2 introduced a Route::auth() helper which generates all of the authentication routes for you. In previous versions of Laravel it was common to copy the authentication routes from the docs.

While not required, you may up update your code to use this new helper. If so, be sure to review the URIs to ensure they match. For example, Route::auth() generates a password/reset URI, instead of password/email.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ Laravel 5.2 condenses the default User model dramatically. Since your Tobuli/Entities/User.php differs from the Laravel 5.1 default, you will need to compare yours against the 5.2 version and merge any changes.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ pluck, keys, zip, collapse, flatten, flip now return a collection in Laravel 5.2. You should review your usage of these methods.

Shift found potential uses of these methods in:

  • ModalHelpers/AlertModalHelper.php
  • ModalHelpers/CustomEventModalHelper.php
  • ModalHelpers/DeviceModalHelper.php
  • ModalHelpers/GeofenceModalHelper.php
  • ModalHelpers/MonitoringModalHelper.php
  • ModalHelpers/ReportModalHelper.php
  • ModalHelpers/SendCommandModalHelper.php
  • Tobuli/Importers/Device/Importer.php
  • Tobuli/Validation/GeofenceFormValidator.php
  • Tobuli/Views/Frontend/ObjectsList/form.blade.php
  • app/Console/Commands/CheckPositionsCommand.php
  • app/Console/PositionsKeys.php
  • app/Console/PositionsStack.php
  • app/Console/ProcessManager.php
  • app/Http/Controllers/Admin/AsaasClientesController.php
  • app/Http/Controllers/Admin/ClientsController.php
  • app/Http/Controllers/Admin/InstituicaoPagamentoController.php
  • app/Http/Controllers/Admin/SmsGatewayController.php
  • app/Http/Controllers/Frontend/ChatController.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ slice, chunk, and reverse methods now preserve keys on the collection in Laravel 5.2. You should review your usage of these methods.

Shift found potential uses of these methods in:

  • Tobuli/Entities/Chat.php
  • Tobuli/Helpers/Formatter/Unit/Unit.php
  • Tobuli/Helpers/GeoAddressHelper.php
  • Tobuli/Helpers/GeoLocation/GeoServices/GeoGeocodio.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

ℹ️ Laravel 5.2 updated the database session driver. If you are using the database driver, you will need to add the user_id, ip_address, and user_agent columns to your session database table.

If your application is currently using the sessions table, you may generate a custom migration for this command by running:

php artisan make:migration add_laravel52_columns_to_sessions_table

Then copy and paste the contents from Shift's AddLaravel52ColumnsToSessionsTable class to upgrade your existing table.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ Laravel 5.2 updated the public/.htaccess to handle the Authorization header. Since your public/.htaccess file differed from the Laravel default, you will need to review the Laravel 5.2 version and merge any changes.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

❌ Laravel 5.2 updated some of the default validation messages. Since your resources/lang/en/validation.php differed from the Laravel default, you will need to review the Laravel 5.2 version and merge any changes.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner 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.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ The Eloquent and query builder pluck method which returned a single column value was deprecated in Laravel 5.1 and changed in Laravel 5.2 to return an array of column values. Instead, you should use the value method to get a single column value.

Since the pluck method also exists for collections, Shift could not reliably automate this change. You should review the following uses of pluck to see if they should be changed to value:

  • ModalHelpers/AlertModalHelper.php
  • ModalHelpers/CustomEventModalHelper.php
  • ModalHelpers/DeviceModalHelper.php
  • ModalHelpers/GeofenceModalHelper.php
  • ModalHelpers/MonitoringModalHelper.php
  • ModalHelpers/ReportModalHelper.php
  • ModalHelpers/SendCommandModalHelper.php
  • Tobuli/Importers/Device/Importer.php
  • Tobuli/Validation/GeofenceFormValidator.php
  • app/Http/Controllers/Admin/AsaasClientesController.php
  • app/Http/Controllers/Admin/ClientsController.php
  • app/Http/Controllers/Admin/InstituicaoPagamentoController.php
  • app/Http/Controllers/Admin/SmsGatewayController.php
  • app/Http/Controllers/Frontend/ChatController.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ Shift updated code within your application which was deprecated in Laravel 5.1 and removed in a future version of Laravel. These deprecations include:

  • The service container bindShared method has been deprecated in favor of the singleton method.
  • The collection fetch method has been deprecated in favor of the pluck method.
  • The array_fetch helper has been deprecated in favor of the array_pluck method.

Given the generic naming of these methods, you should review this commit carefully to verify these changes.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ Shift updated code within your application which was deprecated in Laravel 5.2 and removed in a future version of Laravel. These deprecations include:

  • The collection, Eloquent, and query builder lists method has been renamed to pluck.
  • The Str::randomBytes function was removed in favor of the random_bytes native PHP function.
  • The Str::equals function was removed in favor of the hash_equals native PHP function.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

ℹ️ To improve performance by caching your configuration, Laravel recommends you only use the env() helper within configuration files and use config() everywhere else. Once you are running the latest version of Laravel, you may use the Laravel Fixer to automate this conversion.

Shift found potential uses of env() in:

  • app/Console/Commands/CheckServerCommand.php
  • app/Exceptions/Handler.php
  • app/Providers/ConfigurableMailServiceProvider.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ Since you are upgrading from an older version of Laravel, Shift defaulted your customized configuration files to improve the automation in your next Shift. This was done in a separate commit so you may easily reference the changes and backfill your customizations once you are done Shifting. Future Shifts (Laravel 6+) will preserve your true customizations by merging them back in with the defaults.

  • config/auth.php
  • config/broadcasting.php
  • config/cache.php
  • config/database.php
  • config/mail.php
  • config/queue.php
  • config/services.php
  • config/session.php

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

ℹ️ Laravel 5.2 removed the pretend mail configuration option. If you were using pretend, use the log driver instead.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

⚠️ Laravel 5.2 upgraded some of the Node package dependencies. You should to compare your package.json with the Laravel 5.2 version to upgrade your dependencies.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

ℹ️ Laravel 5.2 no longer uses the phpspec/phpspec package. Unless you require this package for your application, you may remove it from your composer.json development dependencies.

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

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

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

@uilll

uilll commented Jun 3, 2023

Copy link
Copy Markdown
Owner Author

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

  • app/Exceptions/Handler.php
  • config/app.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