thgs / amphp-bootstrap
A package that guides the boot process of an Amphp HTTP server
Requires
- php: >=8.2
- ext-pcntl: ^8.2
- amphp/http-server: ^3
- amphp/http-server-router: ^2
- amphp/http-server-session: ^3.0
- amphp/http-server-static-content: ^2
- amphp/log: ^2
- amphp/websocket-server: ^4.0
Requires (Dev)
- amphp/php-cs-fixer-config: ^2.0.1
- amphp/phpunit-util: ^3.0
- illuminate/container: ^11.22
- phpunit/phpunit: ^9
- psalm/phar: ^5.19
- rdlowrey/auryn: ^1.4
README
Note that this package is at an experimental/exploratory stage.
This is a convenience package that boots an Amphp HTTP server. It exports configuration objects that are used as input and loaders for the config for a few basic formats. It requires a container implementation to be adapted to an interface, however some basic adapters are already provided for some container packages.
Features
- With the container integration you can setup your routes and use DI.
Usage
You can boot it like this, example below is with Auryn Injector.
use Auryn\Injector; use thgs\Bootstrap\Bootstrap; use thgs\Bootstrap\Config\Loader\PhpFileLoader; use thgs\Bootstrap\DependencyInjection\AurynInjector; require \dirname(__DIR__) . '/vendor/autoload.php'; // Loader for config.php which contains the main configuration $loader = new PhpFileLoader(getcwd() . '/' . ($argv[1] ?? 'config.php')); // Pick an injector $injector = new AurynInjector(new Injector()); // Finally, boot everything new Bootstrap($loader->load(), $injector);
See
examples/
directory for a sample configuration. All configuration objects
contain the various options you could set up using Amphp directly as
arguments of the constructor.
Out of the box this package supports the below injectors/containers: