waglpz / webapp-middleware
Web App Middleware Components
2.2.0
2024-09-02 21:44 UTC
Requires
- php: ^8.2
- ext-apcu: *
- moddengine/dice: ^4.1
- phpro/api-problem: ^1.6
- psr/http-message: ^1.0
- waglpz/webapp-security: ^2.1
Requires (Dev)
- doctrine/coding-standard: ^11.1
- nunomaduro/mock-final-classes: ^1.2
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-phpunit: ^1.1
- phpstan/phpstan-strict-rules: ^1.5
- phpstan/phpstan-symfony: ^1.1
- phpstan/phpstan-webmozart-assert: ^1.1
- phpunit/phpunit: ^10.0
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.7
- symfony/var-dumper: ^7.0
This package is auto-updated.
Last update: 2024-10-02 23:07:36 UTC
README
Install via composer
composer require waglpz/webapp-middleware
Working with sources within Docker
Clone Project in some Directory git clone https://github.com/waglpz/webapp-middleware.git
Go into Directory webapp-middleware
and run: bash ./bin/start.sh
to start working within Docker Container.
To stop and clean run: bash ./bin/clean.sh
Composer using from Docker Container
- Install Vendor Dependencies
composer install
- Display Waglpz Composer commands:
composer list | grep waglpz
- Check Source Code vitality:
composer waglpz:check:normal
- Check Source Code Styles:
waglpz:cs-check
- Automatic fix Source Code Styles Errors:
waglpz:cs-fix
- Check Source Code vitality:
Create and Call Middleware Stack
Example PHP code
$request; \assert($request instanceof \Psr\Http\Message\ServerRequestInterface); $middleware_1; \assert($middleware_1 instanceof Waglpz\Webapp\Middleware\Middleware); $middleware_2; \assert($middleware_2 instanceof Waglpz\Webapp\Middleware\Middleware); $middleware_3; \assert($middleware_3 instanceof Waglpz\Webapp\Middleware\Middleware); $finnaly; \assert(\is_callable($finnaly)); $middlewares = [ $middleware_1,// execute first $middleware_2,// execute second $middleware_3 // executes third ]; $middlewareStack = new Waglpz\Webapp\Middleware\MiddlewareStack($middlewares); $response = $middlewareStack($request); // or exact same as manual call $response = $middleware_1( $request, fn ($request) => $middleware_2( $request, fn ($request) => $middleware_3( $request, fn ($request) => $finnaly( $request ) ) ) ); \assert($response instanceof \Psr\Http\Message\ResponseInterface)