The new Laravel 6.0 is a LTS release and continues the improvements made in Laravel 5.8 by introducing semantic versioning, compatibility with Laravel Vapor, improved authorization responses, job middleware, lazy collections, sub-query improvements, the extraction of frontend scaffolding to the laravel/ui Composer package, and a variety of other bug fixes and usability improvements.
Some new features in the incoming 6.0 version are:
- Semantic Versioning
- Laravel Vapor Compatibility
- Improved Authorization Responses
- Job Middleware
- Lazy Collections
- Eloquent Subquery Enhancements
- Laravel UI
PHP 7.2 + required
Support for PHP 7.1 will end from December 2019 . Therefore, Laravel 6.0 requires PHP 7.2 or greater.
Updating Dependencies
Update your laravel / framework dependency to 6.0 in your composer.json file.
Next, examine any 3rd party packages consumed by your application and verify you are using the proper version for Laravel 6 support.
Carbon 2.0
Upgrade the Carbon 1.0 to Carbon 2.0. Laravel 6 does not support Carbon 1.0 anymore.
Database
The capsule table Method
The signature of the Illuminate\Database\Capsul\Manager class’ table method has updated to accept a table alias as its second argument. If you are using illuminate/ outside of a Laravel application, you should update any calls to this method accordingly:
1 2 3 4 5 6 7 |
/** * Get a fluent query builder instance. * * @param \Closure|\Illuminate\Database\Query\Builder|string $table * @param string|null $as * @param string|null $connection * @return \Illuminate\Database\Query\Builder */ public static function table($table, $as = null, $connection = null) |
The cursor method
In the laravel 6, The cursor method now returns an instance of Illuminate\Support\LazyCollection instead of a Generator The LazyCollections may be iterated just like a generator:
1 2 3 4 5 6 |
$users = App\User::cursor(); foreach ($users as $user) { // } |
Requests
The Input facade
The Input facade, which was primarily a duplicate of the Request facade, has been removed. If you are using the Input::get method, you should now call the Request::input method. All other calls to the Input facade may simply be updated to use the Request facade.
Authorized Resources & viewAny
Authorization policies attached to controllers using the authorizeResource method should now define a viewAny method, which will be called when a user accesses the controller’s index method. Otherwise, calls to the index method of the controller will be rejected as unauthorized.
Storage
URL Generation
In previous releases of Laravel, passing associative array parameters to the route helper or URL::route method would occasionally use these parameters as URI values when generating URLs for routes, even if the parameter value had no matching key within the route path.
For example, consider the following route:
1 2 3 4 5 6 7 8 9 |
Route::get('/profile/{location}', function ($location = null) { // })->name('profile'); // Laravel 5.8: http://example.com/profile/active echo route('profile', ['status' => 'active']); // Laravel 6.0: http://example.com/profile?status=active echo route('profile', ['status' => 'active']); |
This change affected The action helper and URL::action method
1 2 3 4 5 6 7 |
Route::get('/profile/{id}', 'ProfileController@show'); // Laravel 5.8: http://example.com/profile/1 echo action('ProfileController@show', ['profile' => 1]); // Laravel 6.0: http://example.com/profile?profile=1 echo action('ProfileController@show', ['profile' => 1]); |
Validation
FormRequest validationData Method
The form request’s validationData method was changed from protected to public. If you are overriding this method in your implementation, you should update the visibility to public.
String & Array Helpers
All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework.
To replace these helpers to must use the Illuminate\Support\Str and Illuminate\Support\Arr classes
Source: https://laravel.com/
Hope it will be helpful for you. If you have any issue feel free to raise a ticket at https://bagisto.uvdesk.com/en/