Quick Summary
If all you’re doing is dropping the
@routes Blade directive into a view somewhere and using the JavaScript route() helper function later, you only really need to worry about one thing:route() with any arguments returns a string now, so:
- Anywhere you’re calling
.url()to get a literal string, remove it - Anywhere you’re passing route parameters using
.with(), pass them as the second argument toroute()instead - Anywhere you’re passing query parameters using
.withQuery(), pass them along with your route parameters in the second argument toroute(). (If any of their names collide with your route parameters, nest your query parameters under a_querykey.)
New Features
Route Model Binding Support
Ziggy now fully supports Laravel’s route-model binding functionality. Previously, Ziggy could accept an object as a parameter and use itsid key as the actual parameter value in the URL. This feature has been enhanced to:
- Fully support custom scoped route-model binding defined in route definitions (e.g.,
/users/{user}/posts/{post:uuid}) - Support implicit route-model binding defined by type-hinting controller methods and closures
slug key into the route() helper:
Parameter Checking with current()
Ziggy’s current() method can now be passed an object of parameters as the second argument, and will return whether those parameter values match in the current URL.
Example:
High Impact Changes
route() Now Returns a String
If you are chaining methods onto a route(...) call with arguments, such as route('posts.show').url() or route('home').withQuery(...), remove the chained methods.
Calls specifically to route() with no arguments are not affected and will still return an instance of the Router class, so things like route().current() and route().params still work as expected.
Before:
url() Method Removed
Because route(...) now returns a string directly, the url() method is no longer necessary. You can safely remove it by finding and replacing instances of '.url()' with '' (nothing).
Before:
Medium Impact Changes
Default ziggy:generate Path Changed
The default output path changed from resources/assets/js/ziggy.js to resources/js/ziggy.js to align with Laravel 5.7+ directory structure.
whitelist and blacklist Renamed
All whitelist and blacklist functionality, including config keys and methods, was renamed:
Before:
Boolean Query Parameters Encoded as Integers
Ziggy’sroute() function will now encode boolean query parameters as integers (0/1) instead of strings ('true'/'false').
Before:
Low Impact Changes
with() and withQuery() Methods Removed
with() and withQuery() Methods Removed
Instead of After:
with(), pass parameters as the second argument to route().Instead of withQuery(), pass query parameters in the same object with regular parameters. If you have query parameters and named parameters with the same name, use the special _query key.Before:Route Facade Macros Removed
Route Facade Macros Removed
Instead of using these macros in your route files, set the routes to include/exclude in After:
config/ziggy.php.Before:RoutePayload Renamed to Ziggy
RoutePayload Renamed to Ziggy
The After:
->compile() method was removed in favor of constructing a new instance and calling ->toArray() or ->toJson().Changes:- The application router instance is now resolved internally (no longer passed to constructor)
new Ziggy(...)now takes only 2 arguments:$groupand$url- The default value of
$basePortchanged fromfalsetonull
getRoutePayload() Method Removed
getRoutePayload() Method Removed
UrlBuilder Class Removed
UrlBuilder Class Removed
Refer to the
template() getter on the new Route class if you need to re-implement this functionality.baseProtocol and baseDomain Properties Removed
baseProtocol and baseDomain Properties Removed
Both these values were inferred from the
baseUrl property, which is set to your app URL. Refer to the template() getter on the new Route class if you need to re-implement this functionality.Config Key Prefixes Removed
Config Key Prefixes Removed
The following configuration properties were renamed:After:
namedRoutes→routesdefaultParameters→defaultsbaseUrl→urlbasePort→port
filter() Method Made Fluent
filter() Method Made Fluent
The After:
filter() method now returns an instance of Ziggy instead of a collection of routes.Before:Unused PHP Methods Removed
Unused PHP Methods Removed
The following unused methods on the
Ziggy class were removed:appendRouteToList()isListedAs()except()only()(redundant/unnecessary)
Internal Methods Made Private
Internal Methods Made Private
The following internal methods are now private:On
Ziggy class:nameKeyedRoutes()resolveBindings()applyFilters()group()
CommandRouteGenerator class:generate()
Undocumented JavaScript Methods Removed
Undocumented JavaScript Methods Removed
Several undocumented methods and properties on the
Router class were removed.Removed properties:name- use the name you were passing intoroute()as the first argumentabsolute- use the value you were passing intoroute()as the third argumentziggy- use the globalZiggyconfiguration objecturlBuilder- refer to thetemplate()getter on the newRouteclasstemplate- refer to thetemplate()getter on the newRouteclassurlParams- use the value you were passing intoroute()as the second argumentqueryParams- use the value you were passing intowithQuery()hydrated- use the returned URL string
normalizeParams()- refer to the internal_parse()methodhydrateUrl()- use the returned URL stringmatchUrl()- usecurrent()or refer to thecurrent()method on the newRouteclassconstructQuery()- use the returned URL stringextractParams()- refer to the_dehydrate()method on theRouterclassparse()- use the returned URL stringtrimParam()- use.replace(/{|\??}/g, '')
Main Build Asset Renamed
Main Build Asset Renamed
Ziggy’s main build asset/entrypoint is now called
index.js instead of route.js.Ziggy’s main JavaScript source and dist files are now called index.js instead of route.js.check() Method Deprecated
check() Method Deprecated
Use
route().has() instead:Migration Steps
Update config/ziggy.php
Rename config keys:
whitelist→onlyblacklist→exceptnamedRoutes→routesdefaultParameters→defaultsbaseUrl→urlbasePort→port
Update ziggy:generate path (if customized)
If you specified a custom path for
ziggy:generate, update it from resources/assets/js/ziggy.js to resources/js/ziggy.js.Getting Help
If you encounter issues during the upgrade process:- Review the GitHub pull requests for detailed changes
- Check existing issues or open a new one
- Consult the Ziggy documentation for updated usage examples