zinvapel / symfony-basis-bundle
There is no license information available for the latest version (0.1.5) of this package.
Common classes for symfony service
Package info
github.com/zinvapel/symfony-basis-bundle
Type:symfony-bundle
pkg:composer/zinvapel/symfony-basis-bundle
0.1.5
2021-03-01 06:37 UTC
Requires
- php: ^7.4 || ^8.0
- zinvapel/enumeration: ^1.0.0
Requires (Dev)
- phpstan/phpstan: ^0.12.59
- sensiolabs/security-checker: ^6.0
- squizlabs/php_codesniffer: ^3.5
- symfony/dependency-injection: ^5.0
- symfony/http-kernel: ^5.0
- symfony/serializer: ^5.0
- symfony/validator: ^5.0
- symfony/yaml: ^5.0
Suggests
- symfony/dependency-injection: If using as Symfony bundle
- symfony/http-kernel: If using as Symfony bundle
- symfony/serializer: If using as Symfony bundle
- symfony/validator: If using as Symfony bundle
- symfony/yaml: If using as Symfony bundle
Provides
None
Conflicts
None
Replaces
None
README
Contains common things for creation of Symfony application. Basically, can be used for every PHP application.
Versions
Version X.Y.Z imply:
- X - const 1 before concepts does not changed
- Y - every update contains new features
- Z - bug fixes
BasisBundle for Symfony users
Plug BasisBundle into your bundles.php.
Explain configuration:
basis: routes: get_user: context: factory_type: denormalize data_extractor: 'route', 'empty', 'json', 'post_json' dto_class: Zinvapel\Basis\BasisBundle\Regular\Dto\Service\EmptyDto constraints_provider: Zinvapel\Basis\BasisBundle\Regular\Dto\Service\EmptyDto::getConstraints service: some.service.name responses: Some\Dto\Name: factory_type: no_content status_code: 204 custom: factory
This config will generate basis.routes.get_user.controller service, instance of Zinvapel\Basis\BasisBundle\Http\Flow\Controller.
context.factory_typedefines factory, instance ofZinvapel\Basis\BasisBundle\Http\Flow\Context\Factory\ContextFactoryInterface. This factory respond for transformation Request intoZinvapel\Basis\BasisBundle\Core\Dto\ServiceDtoInterface. Can be:denormalize- extracts data from Request, validates it and assembleServiceDtoInterfacecustom- indicates to take service name from custom parameter.
context.custom- user defined factory.context.data_extractordefine how to extract data from request. Can be:route- from route parametersempty- returns empty arrayjson- gets json from body and converts into associative arraypost_json- combinesrouteandjson
context.dto_classdefines class, instance ofZinvapel\Basis\BasisBundle\Core\Dto\ServiceDtoInterface, into which Request will be converted.context.constraints_providerdefines callable, which returns Symfony constraints array for Request validation.servicedefines instance ofZinvapel\Basis\BasisBundle\Core\ServiceInterface. Presents route business logic, accepts the aboveServiceDtoInterface, returnsZinvapel\Basis\BasisBundle\Core\Dto\StatefulDtoInteface.responses.Some\Dto\Namedefines how convertSome\Dto\Name, instance ofZinvapel\Basis\BasisBundle\Core\Dto\StatefulDtoInteface, to Symfony Response.responses.X.factory_typedefines response factory, can be:no_contentjsoncustom
responses.X.status_codedefines status code.
Use env ZINVAPEL_BASIS_HTTP_FLOW_DEBUG for force display all HTTP exceptions
OpenApiAssertionBundle (deep beta)
Generate assertions and classes from Swagger documentation. Provide one command:
$ php bin/console zinvapel:oa:parse-swagger <swagger.yaml> [--target <target> [--class <className>]] Where: <swagger.yaml> - path to yaml file with swagger spec <target> - one of 'full', 'object', 'http' <className> - for target 'object'. Generate just this class
Result examples:
- Class
ChatIdMessageMessageIdPatchDto0DtoErrorsItemDto: final class ChatIdMessageMessageIdPatchDto0DtoErrorsItemDto { /** * @Serializer\Groups({"body"}) */ private ?string $path; /** * @Serializer\Groups({"body"}) */ private ?string $error; public function setPath(?string $path = null): self { $this->path = path; return $this; } public function getPath(): ?string { return $this->path; } public function setError(?string $error = null): self { $this->error = error; return $this; } public function getError(): ?string { return $this->error; } }
- Assertions
ChatWithStatDto1StatDto: new Assert\Collection([ 'allowExtraFields' => true, 'fields' => [ 'unreadCount' => [ new Assert\Type([ 'type' => 'integer', ]), new Assert\GreaterThanOrEqual([ 'value' => 0, ]), ], 'mentionsCount' => [ new Assert\Type([ 'type' => 'integer', ]), new Assert\GreaterThanOrEqual([ 'value' => 0, ]), ], ], ])