1. Go to this page and download the library: Download sirix/mezzio-radixrouter 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/ */
sirix / mezzio-radixrouter example snippets
// In config/config.php or similar configuration file
$aggregator = new ConfigAggregator([
// ... other config providers
\Sirix\Mezzio\Router\RadixRouter\ConfigProvider::class,
// ... other config providers
]);
// In config/autoload/dependencies.php or similar configuration file
use Mezzio\Router\RouterInterface;
use Sirix\Mezzio\Router\RadixRouter;
use Sirix\Mezzio\Router\RadixRouterFactory;
return [
'dependencies' => [
'factories' => [
RouterInterface::class => RadixRouterFactory::class,
],
],
];
// In config/routes.php or similar
$app->get('/api/users', [UserListHandler::class], 'api.users');
$app->get('/api/users/:id', [UserDetailsHandler::class], 'api.user');
$app->post('/api/users', [CreateUserHandler::class]);
// Matches both "/hello" and "/hello/john"
$app->get('/hello/:name?', [HelloHandler::class], 'hello');
// In the handler, you can access $request->getAttribute('name'); // null or "john"
// Matches: "/archive", "/archive/2025", "/archive/2025/08"
$app->get('/archive/:year?/:month?', [ArchiveHandler::class], 'archive');
// Attributes:
// year => null or e.g. "2025"
// month => null or e.g. "08"
// Matches any sub-path under /files, e.g. "/files", "/files/images/cat.png"
$app->get('/files/:path*', [FilesHandler::class], 'files');
// Attribute:
// path => '' (empty string) for "/files" or the full remainder like "images/cat.png"
// In config/autoload/router.global.php or similar
use Sirix\Mezzio\Router\Enum\CacheConfig;
return [
'router' => [
'radix' => [
CacheConfig::Enabled->value => true,
CacheConfig::File->value => 'data/cache/radix-cache.php',
],
]
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.