8 minutes read
Laravel retrospective: what changed since version 5.8?
Table of contents
Introduction
You may belong to a group of people who left Laravel a few years ago and would like a quick summary of everything that changed now that you are coming back.
Well, this is your lucky day. Instead of letting you pour hours into reading every upgrade guide, I leveraged the power of AI to compile a (non-exhaustive) list that will give you a great overview.
Changes in the directory structure
Moved directories
- In Laravel 9, the resources/lang directory has been moved to the root project directory.
New directories
- factories: in Laravel 8, model factories were rewritten to support classes, and they are stored in the
database/factoriesdirectory. - seeders: still in Laravel 8 , seeder classes are now stored in the
database/seedersdirectory.
Removed or changed functionalities
- Authentication scaffolding moved to laravel/ui repository.
- The
str_andarray_helpers were removed from the framework in Laravel 6.0 and moved to the laravel/helpers package. - The
Inputfacade was removed in Laravel 6.0, and developers are encouraged to use theRequestfacade instead. - The
mandrillandsparkpostmail drivers were removed in Laravel 6.0. - The
rackspacestorage driver was removed in Laravel 6.0. - The undocumented
addHiddenandaddVisiblemethods were removed from Eloquent in Laravel 7.0. - The undocumented
promotionMarkdown mail component was removed in Laravel 7.0. - Support for duplicate route names was removed in Laravel 7.0.
- Factory “types” feature was removed from Eloquent in Laravel 7.0.
- The
retryAftermethod and property were renamed tobackoffin Laravel 8.0. - The
timeoutAtproperty was renamed toretryUntilin Laravel 8.0. - The
allOnQueue()andallOnConnection()methods were removed when using job chaining in Laravel 8.0. - The default Markdown mail templates were changed in Laravel 7.0 and 8.0, and the old templates were removed.
- The
passwordvalidation rule was renamed tocurrent_passwordin Laravel 9.0. - The Eloquent model’s
$datesproperty was deprecated in Laravel 10.0, and developers are encouraged to use the$castsproperty instead. - The
Redirect::homemethod was deprecated in Laravel 10.0, and developers should useRedirect::route('home')instead. - The deprecated
Bus::dispatchNowanddispatch_nowmethods were replaced withBus::dispatchSyncanddispatch_syncmethods, respectively, in Laravel 10.0. - The deprecated
MocksApplicationServicestrait was removed from tests in Laravel 10.0.
More detailed changes since Laravel 5.8 for each major version
Changes in Laravel 6.0 from 5.8
- PHP 7.2 or greater is now required.
- Carbon 1.x is no longer supported. Upgrade to Carbon 2.0.
str_andarray_helpers have been moved to thelaravel/helperspackage and removed from the framework.- Authorization policies should now define a
viewAnymethod, which will be called when a user accesses the controller’sindexmethod. - The default Redis client has changed from
predistophpredis. To keep usingpredis, set theredis.clientconfiguration option topredis. - The
BelongsTo::updatemethod now functions as an ad-hoc update query, meaning it does not provide mass assignment protection or fire Eloquent events. - The Eloquent model’s
toArraymethod will now cast any attributes that implementIlluminate\Contracts\Support\Arrayableto an array. - The route path for verifying emails has changed from
/email/verify/{id}to/email/verify/{id}/{hash}. - The
Inputfacade has been removed. Use theRequestfacade instead. - The
betweenmethod in the scheduler has updated behavior. - The
mandrillandsparkpostmail drivers have been removed. - The
rackspacestorage driver has been removed. - Passing associative array parameters to the
routehelper orURL::routemethod will now attach these values to the query string instead of using them as URI values when generating URLs for routes.
Changes in Laravel 7.0 from 6.x
- Symfony 5 and PHP 7.2.5 are now required.
- Updated dependencies in
composer.jsonfile. - Authentication scaffolding moved to
laravel/uirepository. - Added
recentlyCreatedTokenmethod toTokenRepositoryInterface. - Renamed
Blade::componentmethod toBlade::aliasComponent. - Introduced first-party support for Blade “tag components”.
- Removed undocumented
addHiddenandaddVisiblemethods from Eloquent. - Added
bootingandbootedmethods to Eloquent. - Changed date serialization format for
toArrayandtoJsonmethods on Eloquent models. - Removed “factory types” feature from Eloquent.
- Updated
getOriginalmethod to respect casts and mutators. - Removed Zend Diactoros library for generating PSR-7 responses and replaced it with
nyholm/psr7. - Changed default Markdown mail templates and removed the undocumented
promotionMarkdown mail component. - Removed support for duplicate route names.
- Integrated Cross-Origin Resource Sharing (CORS) support by default.
- Made
arraysession driver data persistent for the current request. - Automatically escaped values for
assertSee,assertDontSee,assertSeeText,assertDontSeeText,assertSeeInOrder, andassertSeeTextInOrderassertions on theTestResponseclass. - Renamed
Illuminate\Foundation\Testing\TestResponseclass toIlluminate\Testing\TestResponse. - Renamed
Illuminate\Foundation\Testing\Assertclass toIlluminate\Testing\Assert. - Updated the
differentvalidation rule to fail if one of the specified parameters is missing from the request.
Changes in Laravel 8.0 from 7.x
- Minimum PHP version is now 7.3.0.
- Model factories have been rewritten to support classes.
- Seeder and factory namespaces have been added.
- The
retryAftermethod and property have been renamed tobackoff. - The
timeoutAtproperty has been renamed toretryUntil. - The
allOnQueue()andallOnConnection()methods have been removed when using job chaining. - Paginator now uses the Tailwind CSS framework for default styling.
- Automatic controller namespace prefixing is now set to
nullby default in RouteServiceProvider. - The
decodeResponseJsonmethod in the TestResponse class no longer accepts arguments. - The
assertExactJsonmethod now requires numeric keys of compared arrays to match and be in the same order. UseassertSimilarJsonfor comparing without requiring order.
Changes in Laravel 9.0 from 8.x
- PHP 8.0.2 is now required.
- Updated dependencies in
composer.json, includinglaravel/framework,nunomaduro/collision, and replacingfacade/ignitionwithspatie/laravel-ignition. - Migrated from Flysystem 1.x to 3.x, which may require some application changes.
- Replaced SwiftMailer with Symfony Mailer, resulting in several changes related to sending emails.
- Laravel’s dependency on
opis/closurehas been replaced bylaravel/serializable-closure. - The
passwordvalidation rule has been renamed tocurrent_password. - Unvalidated array keys are now excluded from validated data by default.
- The resources/lang directory is now located in the root project directory.
- The
FILESYSTEM_DRIVERenvironment variable has been renamed toFILESYSTEM_DISK.
Changes in Laravel 10.0 from 9.x
- Laravel now requires PHP 8.1.0 or greater and Composer 2.2.0 or greater.
- Update several dependencies in
composer.jsonfile for Laravel 10 support. - Remove or update the
minimum-stabilitysetting in your application’scomposer.jsonfile. - Use
app()->usePublicPath(__DIR__.'/public')instead of bindingpath.publicinto the container for customizing “public path”. - Remove the call to the
registerPoliciesmethod from thebootmethod of your application’sAuthServiceProvider. - Schedule the
cache:prune-stale-tagsArtisan command for Redis cache tags support. - Update how to retrieve the grammar’s raw string value for database expressions by using the
getValuemethod instead of casting to a string. - Pass a string connection name as the first argument to the
Illuminate\Database\QueryExceptionconstructor. - Remove the use of the deprecated Eloquent model’s
$datesproperty and use the$castsproperty instead. - Rename the
getBaseQuerymethod on theIlluminate\Database\Eloquent\Relations\Relationclass totoBase. - Use the
lang:publishArtisan command to publish the language directory in new Laravel applications. - Update your application to work with Monolog 3.x by reviewing Monolog’s upgrade guide and updating any third-party packages.
- Replace the deprecated
Bus::dispatchNowanddispatch_nowmethods withBus::dispatchSyncanddispatch_syncmethods, respectively. - Optionally, rename the
$routeMiddlewareproperty of theApp\Http\Kernelclass to$middlewareAliases. - Update the return values of the
RateLimiter::attemptmethod. - Remove the deprecated
Redirect::homemethod and useRedirect::route('home')instead. - Remove the deprecated
MocksApplicationServicestrait from your tests and use fakes instead, such asEvent::fake,Bus::fake, andNotification::fake. - Update closure based custom validation rules to handle the new behavior of the
$failcallback.
Official packages added since Laravel 5.8
The following packages have been added since Laravel 5.8:
- Breeze
- Cashier (Paddle)
- Folio
- Fortify
- Homestead
- Jetstream
- Mix
- Octane
- Pennant
- Pint
- Prompts
- Sail
- Sanctum
- Valet
Did you like this article? Then, keep learning:
- Understand Laravel internals with clear explanation for better mastery
- Explore detailed Laravel 10 upgrade instructions after Laravel 9 changes
- Dive into all new features and changes in Laravel 10 release
- Upgrade guide for Laravel 11 to keep app current after Laravel 10
- New features and changes in Laravel 11 after Laravel 10
- Early look at upcoming Laravel 12 complements upgrade progression knowledge
- Learn how to incrementally upgrade Laravel 8 to 9 mindfully
- Discover 20+ best practices to improve Laravel code beyond version changes
- Learn about recommended official Laravel packages introduced since Laravel 5.8
- Complete history of Laravel versions complements the Laravel retrospective
0 comments