Download the PHP package guhemama/http-precondition-bundle without Composer
On this page you can find all versions of the php package guhemama/http-precondition-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download guhemama/http-precondition-bundle
More information about guhemama/http-precondition-bundle
Files in guhemama/http-precondition-bundle
Package http-precondition-bundle
Short Description Introduces route preconditions when using the Symfony HttpKernel component.
License MIT
Informations about the package http-precondition-bundle
HTTP Precondition Bundle
This bundle introduces a Precondition
attribute that can be used
to check for certain conditions when routing. When the conditions are
not met, an exception is thrown (412 Precondition failed
).
Installation
Install the bundle with Composer:
Usage
To define a new precondition, import the Guhemama\HttpPreconditionBundle\Annotations\Precondition
attribute and provide an expression expr
to be evaluated - any valid ExpressionLanguage expression is accepted.
When using the ParamConverter
(Symfony 5) or the MapEntity
(Symfony 6+) attributes,
you can also refer to the mapped entities in the precondition expression:
When the precondition expression evaluates to false, an \Guhemama\HttpPreconditionBundle\Exception\Http\PreconditionFailedHttpException
exception is thrown.
This exception also includes an instance of the Precondition
should you need access to its configured values (e.g. payload
).
Configuration
This bundle depends on the ExpressionLanguage component.
If you have extended the expression language or would like to use
a another instance of it instead of the default one, update the configuration as follows, replacing
my_custom_expression_lang_service
with your service name:
All versions of http-precondition-bundle with dependencies
symfony/http-kernel Version ^6.0|^7.0
symfony/expression-language Version ^6.0|^7.0
symfony/dependency-injection Version ^6.0|^7.0
symfony/config Version ^6.0|^7.0