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/ */
use NckRtl\RouteMaker\Get;
...
#[Get(parameters: ['article:slug'])]
public function show(Article $article): \Inertia\Response
{
return inertia('Article/Show', [
'article' => $article->data->forDisplay(),
]);
}
use NckRtl\RouteMaker\{Get, Post, Put, Delete};
class ArticleController extends Controller
{
#[Get]
public function index(): \Inertia\Response
{
// GET /articles
}
#[Post(middleware: 'throttle:5,1')]
public function store(Request $request): RedirectResponse
{
// POST /articles with rate limiting
}
#[Put(parameters: ['article:slug'])]
public function update(Request $request, Article $article): RedirectResponse
{
// PUT /articles/{article:slug}
}
#[Delete(name: 'articles.remove')]
public function destroy(Article $article): RedirectResponse
{
// DELETE /articles/{id} with custom route name
}
}