PHP code example of lizzyman04 / file-router-laravel
1. Go to this page and download the library: Download lizzyman04/file-router-laravel 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/ */
lizzyman04 / file-router-laravel example snippets
// config/file-router.php
return [
'routes_path' => base_path('routes/pages'), // directory scanned for routes
'prefix' => '', // e.g. 'api' to serve under /api/*
'middleware' => ['web'], // middleware applied to all routes
'cache_dir' => null, // e.g. storage_path('framework/cache/file-router')
];
// routes/pages/users/[id].php
// @methods GET, PUT
use Illuminate\Http\Request;
return function (Request $request, array $params) {
return response()->json([
'id' => $params['id'],
'method' => $request->method(),
]);
};