1. Go to this page and download the library: Download nckrtl/waymaker 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 / waymaker example snippets
use NckRtl\Waymaker\Facades\Waymaker;
Waymaker::routes();
namespace App\Http\Controllers;
use NckRtl\Waymaker\Get;
class ContactController extends Controller
{
#[Get(uri: '{id}')]
public function show(): \Inertia\Response
{
return inertia('Contact');
}
}
use NckRtl\Waymaker\Get;
...
#[Get(parameters: ['article:slug'])]
public function show(Article $article): \Inertia\Response
{
return inertia('Article/Show', [
'article' => $article->data->forDisplay(),
]);
}
class ProjectsController extends Controller
{
public static string $middlewareGroup = 'static';
// Optional extra middleware applied with the group
public static array $routeMiddleware = ['cloudflare.cache'];
#[Get(uri: '/', name: 'projects')]
public function index(): Response { ... }
}
#[Get(uri: '/pricing', name: 'pricing', middlewareGroup: 'static')]
public function pricing(): Response { ... }
#[Get(uri: '/dashboard', name: 'dashboard', middlewareGroup: 'web', middleware: 'auth')]
public function dashboard(): Response { ... }
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php', // Fortify / other non-Waymaker web routes if needed
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
Waymaker::routes(); // applies middleware groups without wrapping in web
},
)
->withMiddleware(function (Middleware $middleware) {
$middleware->group('static', [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\HandleInertiaRequests::class,
\NckRtl\CloudflareCache\Http\Middleware\CacheResponse::class,
]);
})
->create();
use NckRtl\Waymaker\{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
}
}
class ArticleController extends Controller
{
protected static string $routePrefix = 'articles';
protected static array $routeMiddleware = ['auth', 'verified'];
// public static string $middlewareGroup = 'web'; // optional named group
...
use NckRtl\Waymaker\Facades\Waymaker;
Waymaker::routes();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.