- PHP 8.1 or later
- A PSR-7 HTTP message implementation
- A PSR-7 emitter (to send the response to the client)
composer require initphp/routerThe router does not ship a PSR-7 implementation. Any compliant library works; the documentation uses InitPHP HTTP:
composer require initphp/httpRoute everything through a single index.php so the router can match any path.
Apache — public/.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]NGINX:
location / {
try_files $uri $uri/ /index.php?$query_string;
}- A PSR-11 container (
psr/container) if you want the router to resolve controllers/services from your container. See Dependency injection.
Next: Getting started.