PHP code example of haikara / file-base-route
1. Go to this page and download the library: Download haikara/file-base-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/ */
haikara / file-base-route example snippets
// Routerにルーティングファイルの設置場所を渡してインスタンス化
$router = new Router('./routes');
// サブディレクトリ運用の場合はプレフィックスとなるパスを渡す
$router->setBasePath('/sub');
$router->setActionInvoker(
fn (Closure $action) => $container->call($action)
);
$response = $router->handle($request);