PHP code example of nckrtl / route-maker

1. Go to this page and download the library: Download nckrtl/route-maker 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/ */

    

nckrtl / route-maker example snippets


return [
    'method_defaults' => [
        'GET' => ['index', 'show'],
        'POST' => ['store'],
        'PUT' => ['update'],
        'DELETE' => ['destroy'],,
    ],
];

use NckRtl\RouteMaker\Facades\RouteMaker;

RouteMaker::routes();



namespace App\Http\Controllers;

class ContactController extends Controller
{
    public function show(): \Inertia\Response
    {
        return inertia('Contact');
    }
}

Route::get('/contact/{id}', [\App\Http\Controllers\ContactController::class, 'show'])->name('Controllers.ContactController.show');

use NckRtl\RouteMaker\Route;

...

#[Route(parameters: ['article:slug'])]
public function show(Article $article): \Inertia\Response
{
    return inertia('Article/Show', [
        'article' => $article->data->forDisplay(),
    ]);
}

class ArticleController extends Controller
{
    protected static string $routePrefix = 'articles';
    protected static string $routeMiddleware = 'auth:verified';

    ...
bash
php artisan vendor:publish --tag="route-maker-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="route-maker-config"