webservco / application-runner
A PHP component/library. Runs a PSR-15 request handler for the current request and sends the response to the client.
Requires
- php: ^8.4
- psr/http-message: ^2
- psr/http-server-handler: ^1
- webservco/application: ^2
- webservco/emitter: ^2
- webservco/http: ^2
Requires (Dev)
- pds/skeleton: ^1
- phan/phan: ^6
- php-parallel-lint/php-console-highlighter: ^1
- php-parallel-lint/php-parallel-lint: ^1
- phpmd/phpmd: ^3
- phpstan/phpstan: ^2
- phpstan/phpstan-deprecation-rules: ^2
- phpstan/phpstan-phpunit: ^2
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpunit: ^13
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^4
- vimeo/psalm: ^6
- webservco/coding-standards: ^2
- webservco/component-common: ^2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP component/library. Please see webservco/sandbox for an example project using these types of components.
Runs a PSR-15 request handler for the current request and sends the response to the client.
- Related:
webservco/application-default(uses the runner),webservco/emitter(sends the response),webservco/http-request-handler(the request handler)
Installation
composer require webservco/application-runner
Usage
Give the factory something that builds your request handler (the middleware stack). The server application factory in webservco/application-default then asks it for a runner.
use WebServCo\Application\Factory\ApplicationRunnerFactory; $runnerFactory = new ApplicationRunnerFactory( // \WebServCo\Http\Contract\Message\Request\RequestHandler\RequestHandlerFactoryInterface $requestHandlerFactory, ); // \WebServCo\Application\Contract\ApplicationRunnerInterface $runner = $runnerFactory->createApplicationRunner($serverRequest); $runner->run();
run() passes the request to the handler, then emits the response through a StackEmitter that contains a SapiEmitter.
Contracts
| Interface | Implementation | Purpose |
|---|---|---|
Contract\ApplicationRunnerFactoryInterface (webservco/application) |
Factory\ApplicationRunnerFactory |
Creates a runner for a server request. |
Contract\ApplicationRunnerInterface (webservco/application) |
Service\ApplicationRunner |
Handles the request and emits the response. |
Namespaces are relative to WebServCo\Application\.
Notes
The runner is for web requests only. In CLI, SapiEmitter refuses to emit and the emitter stack throws an UnderflowException. Use a command runner (webservco/command) for scripts.
Development
# Start project. ddev start # Install dependencies. ddev c u # Run all validations. ddev c c # Run unit tests. ddev c test:dox