Skip to main content
Looking for a step-by-step walkthrough? The Configure Apivalk how-to covers the same ground with a recommended middleware order and a section on growing your configuration as the app expands.

Basic Setup

To bootstrap Apivalk, you need to create an instance of ApivalkConfiguration and pass it to the Apivalk core class.

Dependency Injection (PSR-11 Container)

Apivalk supports any PSR-11 compliant container (like PHP-DI, Symfony DI, etc.). This allows you to inject dependencies into your controllers.
When a container is provided, Apivalk will use it to instantiate your controllers. If no container is provided, it will simply use new $controllerClass().

Localization

You can configure locale support by passing a LocalizationConfiguration to ApivalkConfiguration. This enables automatic locale resolution from the Accept-Language header on every request.
If no LocalizationConfiguration is provided, Apivalk defaults to English (en). See the Localization guide for full details.

Middleware Stack

You can register global middlewares via the configuration.

Exception Handling

You can provide a custom exception handler callable to format error responses.
For more details, see the Exception Handling documentation.