1. Go to this page and download the library: Download componenta/router-app 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/ */
componenta / router-app example snippets
return [
new Componenta\Http\Router\ConfigProvider(),
new Componenta\Http\Router\App\ConfigProvider(),
];
use Componenta\Http\Router\Attribute\Route;
use Psr\Http\Message\ResponseInterface;
#[Route(
name: 'posts.show',
path: '/posts/[id:\d+]',
methods: 'GET',
middlewares: ['web'],
)]
final readonly class ShowPostController
{
public function __invoke(int $id): ResponseInterface
{
// ...
}
}
use Componenta\Http\Middleware\ConfigKey as MiddlewareConfigKey;
use Componenta\Http\Router\App\Resolver\InterceptedRouteHandlerResolver;
return [
MiddlewareConfigKey::RESOLVERS => [
InterceptedRouteHandlerResolver::class,
],
];
bash
php bin/console.php router:list
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.