webservco / application
A PHP component/library. Interfaces for the application lifecycle (bootstrap, run, shutdown) and for the runner that does the work.
Requires
- php: ^8.4
- psr/http-message: ^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.
Interfaces for the application lifecycle (bootstrap, run, shutdown) and for the runner that does the work.
- Related:
webservco/application-default(default application and its factories),webservco/application-runner(HTTP runner)
Installation
composer require webservco/application
Usage
An application goes through three steps. The entry point (public/index.php or a bin script) calls the first two, and the third usually runs as a shutdown function.
// \WebServCo\Application\Contract\ApplicationInterface $application->bootstrap(); $application->run(); // $application->shutdown() is registered by the default implementation.
You rarely implement ApplicationInterface yourself. Use DefaultApplication from webservco/application-default, and give it an ApplicationRunnerInterface (HTTP) or a CommandRunnerInterface (CLI, from webservco/command).
Contracts
| Interface | Implementation | Purpose |
|---|---|---|
Contract\ApplicationInterface |
DefaultApplication (webservco/application-default) |
bootstrap(), run() and shutdown(). |
Contract\ApplicationRunnerInterface |
ApplicationRunner (webservco/application-runner) |
Does the work inside run(), for example handling an HTTP request. |
Contract\ApplicationRunnerFactoryInterface |
ApplicationRunnerFactory (webservco/application-runner) |
Creates a runner for a PSR-7 server request. |
Namespaces are relative to WebServCo\Application\.
Development
# Start project. ddev start # Install dependencies. ddev c u # Run all validations. ddev c c # Run unit tests. ddev c test:dox