Download the PHP package condenast-ru/basic-api-bundle without Composer
On this page you can find all versions of the php package condenast-ru/basic-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download condenast-ru/basic-api-bundle
More information about condenast-ru/basic-api-bundle
Files in condenast-ru/basic-api-bundle
Informations about the package basic-api-bundle
Basic API Bundle
The bundle for rapid API development without writing boilerplate code
The main purpose of the bundle is to work with DTOs: serialization, deserialization and validation. It doesn't know anything about the database and ORM.
Tasks solved by this bundle:
- Deserializing the request body from JSON to an object or array of objects
- Validating the deserialization result
- Serializing the response to JSON
- Serializing exceptions to JSON
- Extracting typed values from a query string
- Generating API documentation
Installation
Then bundle should be enabled in bundles.php
file
How it works?
The bundle is based on symfony kernel event subscribers, they do the bulk of the work.
API actions are configured using annotations in the controller.
Values from annotations are written to request attributes, which are then used by subscribers.
symfony/serializer
is used for serialization and deserialization,
symfony/validator
is used for validation,
nelmio/api-doc-bundle
is used for API documentation generation.
Usage
API
- Describe how to serialize and deserialize your objects according to the
symfony/serializer
documentation - Describe the validation rules for your objects according to the
symfony/validator
documentation - Configure your controller actions using the annotations provided with this bundle
Example:
CORS
The bundle does not contain anything for CORS, if necessary, use nelmio/cors-bundle
.
API documentation
Install nelmio/api-doc-bundle
and symfony/twig-bundle
and configure according to the documentation,
bundle describers will add anything they can learn about actions to the documentation.
Anything that is missing can be added via annotations to the controller, as written in the documentation
for the nelmio/api-doc-bundle
.
Development
To run a web server with a test application for development and debugging, make sure the Symfony CLI is installed
and run the command make server
.
The test application code is located in the tests/Fixtures/App
directory.
Tests
To run the tests, use the make tests
command.
All versions of basic-api-bundle with dependencies
symfony/config Version ^6
symfony/dependency-injection Version ^6
symfony/error-handler Version ^6
symfony/event-dispatcher Version ^6
symfony/framework-bundle Version ^6
symfony/http-foundation Version ^6
symfony/http-kernel Version ^6
symfony/property-access Version ^6
symfony/serializer Version ^6
symfony/string Version ^6
symfony/validator Version ^6