Starting from https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0:
laravel/framework
to 5.3.*
in composer.json
file.symfony/css-selector
and symfony/dom-crawler
3.1.*
in require-dev section composer.json.Illuminate\Contracts\Bus\SelfHandling
contract; it can be removed from jobs.lists
method on Collection, query builder, and Eloquent query builder objects renamed to pluck
.Route::controller
deprecated.get
, post
, and other route helper functions removed; use Route
facade instead.database
session driver from 5.1 has been renamed to legacy-database
and will be removed.Str::randomBytes
function deprecated; use random_bytes
native PHP function instead.Str::equals
function deprecated; use hash_equals
native PHP function instead.Illuminate\View\Expression
deprecated in favor of Illuminate\Support\HtmlString
.WincacheStore
cache driver removed.boot
method on EventServiceProvider
, RouteServiceProvider
, and AuthServiceProvider
classes. Convert any calls to the removed arguments to use the equivalent facade instead. For example, instead of calling methods on the $dispatcher
argument, you may simply call the Event
facade. Make sure to import any facades used.first
, last
, and where
methods on the Arr
class, in addition to their associated global helper functions, now pass the "value" as the first parameter to the given callback Closure, instead of the "key" being passed first.make:console
command renamed to make:command
.Auth::routes()
method is called in your routes file in order to register the proper routes for the new authentication controllers. If you had any custom logic in the old controllers, ensure it is re-implemented.
sendPasswordResetNotification
method of the Illuminate\Auth\Passwords\CanResetPassword
trait. The User
model must use the new Illuminate\Notifications\Notifiable
trait for password reset emails to be delivered. Don't forget to register the Illuminate\Notifications\NotificationServiceProvider::class
in the providers array of config/app.php
.AuthorizesResources
trait has been merged with the AuthorizesRequests
trait; remove the AuthorizesResources
trait from app/Http/Controllers/Controller.php
.$expression
callback outer-most parentheses are no longer included in the expression passed to your directive callback. Review the Blade extension documentation and verify any custom Blade directives still work.BroadcastServiceProvider
to your app/Providers
directory; get it here, and then add it to the providers array of config/app.php
. Next, add the new broadcasting.php configuration file to the config directory.Cache::extend
method with a closure, $this
will be bound to the CacheManager
instance, enabling the invokation of its methods from within the closure.laravel/cashier
package to the ~7.0
release, which upgrades a few internal methods for compatibility with Laravel 5.3 and is not a breaking change.first
, last
, and contains
collection methods all pass the "value" as the first parameter to their given callback closure, instead of $key
being passed first. This type of change does more harm than good.where
method now performs a loose comparison instead of a strict comparison; to perform a strict comparison, use the whereStrict
method. The 'whereLoosemethod has been removed from the collection class. The
wheremethod also no longer accepts a third parameter to indicate "strictness"; instead use
whereor
whereStrict`.config/app.php
; set it for your application.Illuminate\Http\Request
class on your controller method.Illuminate\Support\Collection
instead of plain arrays, bringing consistency to the returned result types. If you do not want to migrate your query builder results to Collections
, instead chain the all
method to in addition to the get
or pluck
methods to return a plain PHP array and maintaining backwards compatibility.getRelation
method no longer throws a BadMethodCallException
if the relation can't be loaded, and instead throws an Illuminate\Database\Eloquent\RelationNotFoundException
which only affects your app if you were manually catching the BadMethodCallException
.$morphClass
property of Eloquent models removed in favor of a "morph map", which provides support for eager loading and resolves bugs with polymorphic relations. Those relying on the $morphClass
property should migrate to Relation::morphMap
in the boot
method of your AppServiceProvider
.orWhere
constraint it will no longer be converted to normal where. If you were leveraging this feature (for example: using multiple orWhere
constraints in a loop) verify that the first condition is a normal where
to avoid logic issues. If your scopes begin with where
constraints no action is required. If unsure, verify your SQL using the toSql
method.JoinClause
class updated to unify its syntax with query builder and the optional $where
parameter of the on
clause has been removed. Add a "where" condition by explicitly using one of the where
methods offered by the query builder. The operator of the on
clause is now validated and can no longer contain invalid values, and the $bindings
property was removed. In order to manipulate join bindings directly use the addBinding
method.Mcrypt
removed in favor of the newer encryption implementation based on OpenSSL. If still using an Mcrypt
based cipher (defined in config/app.php
), update the cipher to AES-256-CBC
and set your key to a random 32 byte string generated with php artisan key:generate
. If storing encrypted data using the Mcrypt
encrypter, install the laravel/legacy-encrypter
package to decrypt your encrypted data and re-encrypt it using the new OpenSSL encrypter.Illuminate\Container\Container
instance to be passed to its constructor; only affects app if a custom __construct
method has been defined in app/Exceptions/Handler.php
, in which case pass a container instance into the parent::__construct
like so: parent::__construct(app());
unauthenticated
method to your App\Exceptions\Handler
class in order to convert authentication exceptions into HTTP responses. Find the new unauthenticated
method here: https://github.com/laravel/laravel/blob/5.3/app/Exceptions/Handler.phpcan
middleware in $routeMiddleware
property of HTTP kernel to the following class: 'can' => \Illuminate\Auth\Middleware\Authorize::class
can
middleware now throws an instance of Illuminate\Auth\AuthenticationException
if the user is not authenticated. If you were manually catching a different exception type, update your application to catch this exception. This change will not affect most applications.Illuminate\Routing\Middleware\SubstituteBindings
to your web middleware group in app/Http/Kernel.php
.$routeMiddleware
property of your HTTP kernel: 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class
, and once registered add the 'bindings'
element to the api
middleware group array.Illuminate\Notifications\NotificationServiceProvider
in the providers array of config/app.php
. Also add 'Notification' => Illuminate\Support\Facades\Notification::class
to the aliases array of config/app.php
. Use the Illuminate\Notifications\Notifiable
trait in order to receive notifications.resources/views/vendor
directory using the php artisan vendor:publish --tag=laravel-pagination
command which will place the views in the resources/views/vendor/pagination
directory. The default.blade.php
file is used for the default pagination view; edit this file to modify the pagination HTML.expire
configuration items to retry_after
, and Beanstalk configuration's ttr
item should similarly renamed.Illuminate\Queue\SerializesModels
trait now properly serializes instances of Illuminate\Database\Eloquent\Collection
(which is most likely not a breaking change for most applications). If your application is dependent on collections not being re-retrieved from the database by queued jobs, verify that this is not a breaking change.--daemon
option when calling the queue:work
Artisan command; instead php artisan queue:work
will run the worker in daemon mode. To process a single job use the --once
option.database
driver to store queued jobs, drop the jobs_queue_reserved_reserved_at_index
index then drop the reserved
column from the jobs
table (it's no longer required when using the database driver). Then add a new compound index on the queue
and reserved_at columns
: $table->index(['queue', 'reserved_at']);
.JobProcessing
and JobProcessed
no longer contain the $data
property; update your application to call $event->job->payload()
to get the equivalent data.Queue::failing
method in your AppServiceProvider
.--timeout
option for queue workers verify that the PHP pcntl
extension is installed.Queue::push('ClassName@method');
syntax, Eloquent models will no longer be automatically serialized and re-retrieved by the queue. To automatically serialize your Eloquent models for a given job, use the Illuminate\Queue\SerializesModels
trait on your job class with the new push
syntax: Queue::push(new ClassName);
. Route::resource
were not "singularized", which could lead to unexpected behavior when registering route model bindings. In Laravel 5.3, all resource route parameters are singularized by default.Route::resource
, since this behavior defeated the purpose of using route names. If using Route::resource
within a Route::group
call that specified a prefix
, examine all route
helper and UrlGenerator::route
calls to verify that this URI prefix is no longer appended to the route name. If this change causes you to have two routes with the same name, you have two options. First, you may use the names
option when calling Route::resource
to specify a custom name for a given route or add the as
option to your route group.Illuminate\Validation\ValidationException
is now thrown instead of an HttpException
, and if manually catching the HttpException
thrown by a form request, update your catch blocks to catch the ValidationException
instead.has
method to determine if an Illuminate\Support\MessageBag
instance contained any messages, you should use the count
method instead because the has
method now requires a parameter and only determines if a specific key exists in the message bag.null
is no longer considered valid unless the rule set contains the new nullable
rule.laravel/framework
to 5.4.\*
in composer.json
file.phpunit/phpunit
to ~5.7
in composer.json
file.bootstrap/cache/compiled.php
file as it is no longer used by the framework.php artisan view:clear
to avoid Blade errors related to the removal of Illuminate\View\Factory::getFirstLoop()
and run php artisan route:clear
to flush the route cache.axios
.getPolicyFor
method now returns null if no policy is found for the given class. If calling this method directly check for a null response.@section
is automatically escaped. Use the long form style to render unescaped content.$bootstrappers
array in your HTTP or console kernel, rename the DetectEnvironment
entry to LoadEnvironmentVariables
and remove ConfigureLogging
.\*
character was used to define channel name placeholders; change these placeholders to use {foo}
style placeholders (like routes).every
method has been moved to the nth
method to match the method name defined by Lodash.$collection->random(1)
now returns a new collection instance with one item whereas previously this would return a single object. A single object will only be returned if no arguments are supplied.bind
or instance
methods when registering an alias has been removed; instead use the alias
method.make
method no longer accepts a second array of parameters; if you must continue to pass an array of parameters, use the makeWith
method.resolving
and afterResolving
method now must be provided a class name or binding key as the first argument to the method.share
method has been removed from the container; use the singleton
method instead.Illuminate\Console\AppNamespaceDetectorTrait
, instead reference Illuminate\Console\DetectsApplicationNamespace
.orWhere
method the inner conditions now use OR
between each array element.db.connection.{driver}
key in order to resolve a custom database connection, you should now use the Illuminate\Database\Connection::resolverFor
method in the register
method of your AppServiceProvider
.PDO::FETCH_OBJ
is always used. To customize the fetch mode for your application listen for the new Illuminate\Database\Events\StatementPrepared
event.date
cast now converts the column to a Carbon
object and calls the startOfDay
method on the object. To preserve the time
portion of the date use the datetime
cast.belongsToMany
setJoin
method renamed to performJoin
.belongsToMany
getRelatedIds
method renamed to allRelatedIds
.createMany
method of a hasOne
or hasMany
relationship now returns a collection object instead of an array.getPlainForeignKey
method of a hasOne
or hasMany
relationship renamed getForeignKeyName
.chunk
method now requires an orderBy
clause, and an exception will be thrown if not supplied. The method will automatically apply an orderBy
clause on the model's primary key if not supplied.Model::create
and Model::forceCreate
methods moved to the Illuminate\Database\Eloquent\Builder
class.hydrate
method now use the on
method.Model::hydrateRaw
method has been renamed to fromQuery
. If passing a custom connection name to this method use the on
method.whereKey($id)
method will now add a "where" clause for the given primary key value. Previously this would fall into the dynamic "where" clause builder and add a "where" clause for the "key" column. If you used the whereKey
method to dynamically add a condition for the key column you should now use where('key', ...)
instead.factory(User::class, 1)->make()
or factory(User::class, 1)->create()
will now return a collection with one item instead of returning a single model and will only return a single model if the amount is not supplied.Model::newPivot
method signature has been updated to add a new $using
argument.Illuminate\Contracts\Events\Dispatcher
interface in your application rename the fire
method to dispatch
.Event::firing
method has been removed.kernel.handled
using the Illuminate\Foundation\Http\Events\RequestHandled
class.locale.changed
using the Illuminate\Foundation\Events\LocaleUpdated
class.illuminate.log
using the Illuminate\Log\Events\MessageLogged class.Illuminate\Http\Exception\HttpResponseException
has been renamed to Illuminate\Http\Exceptions\HttpResponseException
. Also the Illuminate\Http\Exception\PostTooLargeException
has been renamed to lluminate\Http\Exceptions\PostTooLargeException
.Class@method
syntax is no longer supported.config/mail.php
(see here for details.mailable
. Queuing mail using the Mail::queue
and Mail::later
methods no longer support using closures to configure the mail message.failed_jobs
table, add an exception
column to the table: $table->longText('exception')->after('payload');
clusters
configuration option in the Redis portion of config/database.php
:Illuminate\Foundation\Http\Middleware\VerifyPostSize
has been renamed to Illuminate\Foundation\Http\Middleware\ValidatePostSize
.Illuminate\Routing\Router
class has been renamed to aliasMiddleware()
.getUri
method of the Illuminate\Routing\Route
class has been removed; use the uri
method instead.getMethods
method of the Illuminate\Routing\Route
class has been removed; use the methods
method instead.getParameter
method of the Illuminate\Routing\Route
class has been removed; use the parameter
method instead.getPath
method of the Illuminate\Routing\Route
class has been removed; use the uri
method instead.SessionInterface
. A new Illuminate\Contracts\Session\Session
interface has been defined and used instead. The following code changes should also be applied: All calls to the ->set()
method should be changed to ->put()
. All calls to the ->getToken()
method should be changed to ->token()
. All calls to the $request->setSession()
method should be changed to setLaravelSession()
.laravel/browser-kit-testing
package. You can run the 5.4 testing layer side-by-side with the Laravel 5.3 testing layer. To autoload any new tests you generate using the 5.4 test generators, add the Tests
namespace to your composer.json
file's autoload-dev
block: "psr-4": {"Tests\\": "tests/"}
putenv('APP_ENV=testing')
; instead the APP_ENV
variable is loaded from the .env file.Event
fake's assertFired
method should be updated to assertDispatched
, and the assertNotFired
method should be updated to assertNotDispatched
.Mail
fake has been simplified for the 5.4 release; instead of using the assertSentTo
method, you should now simply use the assertSent
method and utilize the hasTo
, hasCc
, etc. helper methods within your callback.{Inf}
placeholder for pluralizing translation strings, update translation strings to use the *
character instead.trans
helper signature has been updated to remove the unnecessary $domain
argument.forceSchema
method of the Illuminate\Routing\UrlGenerator
class has been renamed to forceScheme
.addError
method has been renamed to addFailure
and the doReplacements
method has been renamed to makeReplacements
.laravel/framework
to 5.5.*
in composer.json
file.App\Console\Kernel
class:fire
methods present on your Artisan commands should be renamed to handle
.optimize
Artisan command is no longer needed. Remove any references to this command from your deployment scripts as it will be removed.authorizeResource
method, the resulting route segment will now be "snake" case, matching the behavior of resource controllers.Auth::basic
and Auth::onceBasic
now throw \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
rather than returning a Response
when authentication fails. This still results in a 401 response being sent to the client; however if your application checked the return value of Auth::basic
in order to return a custom response or implement other behavior on authentication failure, you will now need to handle the UnauthorizedHttpException
.before
method of a policy class will not be called if the class doesn't contain a method matching the name of the ability being checked.database
cache driver, run php artisan cache:clear
after upgrading.belongsToMany
method Eloquent models.getQualifiedRelatedKeyName
method has been renamed to getQualifiedRelatedPivotKeyName
.getQualifiedForeignKeyName
method has been renamed to getQualifiedForeignPivotKeyName
.is
method of an Eloquent model, remove the Model
type-hint from the method allowing the is
method to receive null
as an argument.$events
property on your models should be renamed to $dispatchesEvents
.$parent
property on the Illuminate\Database\Eloquent\Relations\Pivot
class has been renamed to $pivotParent
.BelongsToMany
, HasOneOrMany
, and MorphOneOrMany
classes' create
methods have been modified to provide a default value for the $attributes
argument. Mind the new signatures.exists
property on the model will remain true
.withCount
method will no longer automatically append _count
onto the resulting column name.$user['name']
) or the data_get
helper function.failedValidation
method of that form request, and throw an HttpResponseException
instance containing your custom response.files
method of the Illuminate\Filesystem\Filesystem
class has changed its signature to add the $hidden
argument and now returns an array of SplFileInfo
objects, similar to the allFiles
method as opposed to previously returning an array of string path names.$data
and $callback
arguments were removed from Illuminate\Contracts\Mail\MailQueue
queue and later methods.dispatch_now
or Bus::dispatchNow
method.all
method of the Illuminate\Http\Request
class, update your method signature to reflect the new $keys
argument.$request->has
method will now return true
even if the input value is an empty string or null
, and a new $request->filled
method has been added that provides the previous behavior of the has
method.intersect
method has been removed; you may replicate this behavior using array_filter
on a call to $request->only
.only
method will now only return attributes that are actually present in the request payload, and if you would like to preserve the old behavior use the all
method instead.request
helper will no longer retrieve nested keys. If needed, you may use the input
method of the request
to achieve this behavior: request()->input('filters.date');
seeIsAuthenticated
renamed to assertAuthenticated
dontSeeIsAuthenticated
renamed to assertGuest
seeIsAuthenticatedAs
renamed to assertAuthenticatedAs
seeCredentials
renamed to assertCredentials
dontSeeCredentials
renamed to assertInvalidCredentials
Mail
fake to determine if a mailable was queued during a request, you should now use Mail::assertQueued
instead of Mail::assertSent
. This distinction allows you to specifically assert that the mail was queued for background sending and not sent during the request itself.optimize-autoloader
directive to the config
section of your composer.json
file.Illuminate\Translation\LoaderInterface
interface has been moved to Illuminate\Contracts\Translation\Loader
.public
instead of protected
.__call
method to share variables with a view, these variables will automatically use "camel" case.@php
blade directive no longer accepts inline tags; instead use the full form of the directive.