1. Go to this page and download the library: Download rzl-zone/ziggy-route library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Middleware;
use Inertia\Middleware;
use Illuminate\Http\Request;
use RzlZone\ZiggyRoute\RzlZiggy;
use Illuminate\Foundation\Inspiring;
class HandleInertiaRequests extends Middleware
{
// modify at share method only.
public function share(Request $request): array
{
return [
...parent::share($request),
//! This is ing `@rzlRoutes` directive
"rzlZiggy" => fn(): array => [
...(new RzlZiggy())->jsonConfigsSsr(),
],
// ....other your props config
];
}
}
// config/rzl-ziggy.php
return [
"only" => ["home", "posts.index", "posts.show"],
// other you config...
];
// config/rzl-ziggy.php
return [
"except" => ["_debugbar.*", "horizon.*", "admin.*"],
// other you config...
];
// config/rzl-ziggy.php
return [
"groups" => [
"admin" => ["admin.*", "users.*"],
"author" => ["posts.*"],
],
// other you config...
];
// config/rzl-ziggy.php
return [
/** Default values for dynamic route parameters.
*
* These values will be applied automatically to any route parameter
* that exists in the route URI but is not explicitly passed during route generation.
*
* Useful for things like localization (e.g. `{locale}`), tenant identifiers (e.g. `{team}`),
* or filtering (e.g. `{type}`) without having to always specify them in the frontend.
*
* You can override these at runtime via `URL::defaults([...])`.
*/
"defaults" => [
/** Default for `{locale}` route parameter. CLI `--locale` overrides this value. */
"locale" => env("APP_LOCALE", "en"),
// another example:...
// "type" => "default", // Default value for routes requiring {type}
// "team" => "main", // Default tenant/team identifier (e.g. {team})
],
// other you config...
];
// config/rzl-ziggy.php
return [
"lang" => "ts",
// other you config...
];
// config/rzl-ziggy.php
return [
"output" => [
"name" => "index", // ➔ index.ts or index.js
"path" => [
"main" => "resources/js/rzl-ziggy/routes", // Output folder only
]
],
// other you config...
];
@rzlRoutes(nonce: "your-nonce-here")
// routes/api.php
use RzlZone\Ziggy\RzlZiggy;
Route::get("rzl-ziggy", fn () => response()->json(new RzlZiggy));