The web application bundle (spiral/app
) is shipped with a pre-configured HTTP component. You will need several extensions
to enable it in alternative builds.
To install the extension:
composer require spiral/nyholm-bridge
Activate the component by adding two bootloaders:
public function defineBootloaders(): array
{
return [
// ...
// Fast PSR-7 implementation
\Spiral\Nyholm\Bootloader\NyholmBootloader::class,
// HTTP core
\Spiral\Bootloader\Http\HttpBootloader::class,
// PSR-15 handler
\Spiral\Bootloader\Http\RouterBootloader::class,
// ...
];
}
Read more about bootloaders in the Framework — Bootloaders section.
Note
See how to use custom PSR-15 handler here.
Make sure to configure routing.
The HTTP extension can be configured via app/config/http.php
file:
return [
// default base path
'basePath' => '/',
// default headers
'headers' => [
'Content-Type' => 'text/html; charset=UTF-8'
],
// application level middleware
'middleware' => [
// middleware class name
],
];
Note
The default configuration will be used if such file does not exist.