Laravel retrospective: what changed since version 5.8?
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/factories
directory. -
seeders: still in Laravel 8 , seeder classes are now stored in the
database/seeders
directory.
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
Input
facade was removed in Laravel 6.0, and developers are encouraged to use theRequest
facade instead. - The
mandrill
andsparkpost
mail drivers were removed in Laravel 6.0. - The
rackspace
storage driver was removed in Laravel 6.0. - The undocumented
addHidden
andaddVisible
methods were removed from Eloquent in Laravel 7.0. - The undocumented
promotion
Markdown 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
retryAfter
method and property were renamed tobackoff
in Laravel 8.0. - The
timeoutAt
property was renamed toretryUntil
in 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
password
validation rule was renamed tocurrent_password
in Laravel 9.0. - The Eloquent model’s
$dates
property was deprecated in Laravel 10.0, and developers are encouraged to use the$casts
property instead. - The
Redirect::home
method was deprecated in Laravel 10.0, and developers should useRedirect::route('home')
instead. - The deprecated
Bus::dispatchNow
anddispatch_now
methods were replaced withBus::dispatchSync
anddispatch_sync
methods, respectively, in Laravel 10.0. - The deprecated
MocksApplicationServices
trait 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/helpers
package and removed from the framework. - Authorization policies should now define a
viewAny
method, which will be called when a user accesses the controller’sindex
method. - The default Redis client has changed from
predis
tophpredis
. To keep usingpredis
, set theredis.client
configuration option topredis
. - The
BelongsTo::update
method now functions as an ad-hoc update query, meaning it does not provide mass assignment protection or fire Eloquent events. - The Eloquent model’s
toArray
method will now cast any attributes that implementIlluminate\Contracts\Support\Arrayable
to an array. - The route path for verifying emails has changed from
/email/verify/{id}
to/email/verify/{id}/{hash}
. - The
Input
facade has been removed. Use theRequest
facade instead. - The
between
method in the scheduler has updated behavior. - The
mandrill
andsparkpost
mail drivers have been removed. - The
rackspace
storage driver has been removed. - Passing associative array parameters to the
route
helper orURL::route
method 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.json
file. - Authentication scaffolding moved to
laravel/ui
repository. - Added
recentlyCreatedToken
method toTokenRepositoryInterface
. - Renamed
Blade::component
method toBlade::aliasComponent
. - Introduced first-party support for Blade “tag components”.
- Removed undocumented
addHidden
andaddVisible
methods from Eloquent. - Added
booting
andbooted
methods to Eloquent. - Changed date serialization format for
toArray
andtoJson
methods on Eloquent models. - Removed “factory types” feature from Eloquent.
- Updated
getOriginal
method 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
promotion
Markdown mail component. - Removed support for duplicate route names.
- Integrated Cross-Origin Resource Sharing (CORS) support by default.
- Made
array
session driver data persistent for the current request. - Automatically escaped values for
assertSee
,assertDontSee
,assertSeeText
,assertDontSeeText
,assertSeeInOrder
, andassertSeeTextInOrder
assertions on theTestResponse
class. - Renamed
Illuminate\Foundation\Testing\TestResponse
class toIlluminate\Testing\TestResponse
. - Renamed
Illuminate\Foundation\Testing\Assert
class toIlluminate\Testing\Assert
. - Updated the
different
validation 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
retryAfter
method and property have been renamed tobackoff
. - The
timeoutAt
property 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
null
by default in RouteServiceProvider. - The
decodeResponseJson
method in the TestResponse class no longer accepts arguments. - The
assertExactJson
method now requires numeric keys of compared arrays to match and be in the same order. UseassertSimilarJson
for 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/ignition
withspatie/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/closure
has been replaced bylaravel/serializable-closure
. - The
password
validation 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_DRIVER
environment 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.json
file for Laravel 10 support. - Remove or update the
minimum-stability
setting in your application’scomposer.json
file. - Use
app()->usePublicPath(__DIR__.'/public')
instead of bindingpath.public
into the container for customizing “public path”. - Remove the call to the
registerPolicies
method from theboot
method of your application’sAuthServiceProvider
. - Schedule the
cache:prune-stale-tags
Artisan command for Redis cache tags support. - Update how to retrieve the grammar’s raw string value for database expressions by using the
getValue
method instead of casting to a string. - Pass a string connection name as the first argument to the
Illuminate\Database\QueryException
constructor. - Remove the use of the deprecated Eloquent model’s
$dates
property and use the$casts
property instead. - Rename the
getBaseQuery
method on theIlluminate\Database\Eloquent\Relations\Relation
class totoBase
. - Use the
lang:publish
Artisan 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::dispatchNow
anddispatch_now
methods withBus::dispatchSync
anddispatch_sync
methods, respectively. - Optionally, rename the
$routeMiddleware
property of theApp\Http\Kernel
class to$middlewareAliases
. - Update the return values of the
RateLimiter::attempt
method. - Remove the deprecated
Redirect::home
method and useRedirect::route('home')
instead. - Remove the deprecated
MocksApplicationServices
trait 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
$fail
callback.
Official packages added since Laravel 5.8
The following packages have been added since Laravel 5.8: