pond5 / async-request-bundle
This bundle allows sending requests to a Symfony Messenger transport to be handled later by a consumer
Installs: 477
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 14
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- psr/log: ^1.1|^2.0|^3.0
- symfony/config: ^5.2|^6.0
- symfony/dependency-injection: ^5.2|^6.0
- symfony/event-dispatcher: ^5.2|^6.0
- symfony/http-foundation: ^5.2|^6.0
- symfony/http-kernel: ^5.2|^6.0
- symfony/messenger: ^5.2|^6.0
Requires (Dev)
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^0.12.85
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
README
This bundle allows sending requests to a Symfony Messenger transport to be handled later by a consumer.
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
composer require pond5/async-request-bundle
Applications that don't use Symfony Flex
- Add config file
# config/packages/pond5_async_request.yaml pond5_async_request: #header: X-Request-Async # user defined header name to indicate asynchronous request - X-Request-Async used by default #methods: [DELETE, PATCH, POST, PUT] # HTTP methods that should support async requests transport: async-request # messenger transport name, ignored if messenger routing for Pond5\AsyncRequestBundle\Message\AsyncRequestNotification is configured manually # can be omitted when using transport configured in another file (e.g. messenger.yaml) framework: messenger: transports: async-request: '%env(MESSENGER_TRANSPORT_DSN)%'
- Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require pond5/async-request-bundle
- Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php return [ // ... Pond5\AsyncRequestBundle\Pond5AsyncRequestBundle::class => ['all' => true], ];
Usage
- Add
X-Request-Async
header aDELETE, PATCH, POST, PUT
request, e.g.
curl -i -X POST http://example.org/endpoint -H "X-Request-Async: 1"
Symfony should respond with 202
status code and empty body:
HTTP/1.1 202 Accepted
Content-Length: 0
- Handle the request/consume the message
bin/console messenger:consume
Test
- Install dev dependencies.
composer install
- Run unit tests.
bin/phpunit