Skip to content

Installation

Muhammet Şafak edited this page Jun 9, 2026 · 1 revision

Installation

Requirements

  • PHP 8.1 or later
  • A PSR-7 HTTP message implementation
  • A PSR-7 emitter (to send the response to the client)

Install with Composer

composer require initphp/router

The router does not ship a PSR-7 implementation — bring your own. The wiki uses InitPHP HTTP:

composer require initphp/http

Front controller & URL rewriting

Route every request through a single index.php so the router can match any path.

Apachepublic/.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;
}

Optional dependencies

  • A PSR-11 container (psr/container) if you want the router to resolve controllers/services from your container — see Dependency Injection.

Next: Quick Start.

Clone this wiki locally