Download the PHP package lydic-group/rapid-api-crud without Composer
On this page you can find all versions of the php package lydic-group/rapid-api-crud. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lydic-group/rapid-api-crud
More information about lydic-group/rapid-api-crud
Files in lydic-group/rapid-api-crud
Package rapid-api-crud
Short Description This software enables rapid and flexible Symfony CRUD API development.
License MIT
Informations about the package rapid-api-crud
LYDIC group / Rapid API CRUD Bundle
This software enables rapid and flexible Symfony API CRUD development.
What it does
- Creates an endpoint for CRUD actions on a given entity (configurable)
- Validates the entity by using the annotations in the class
- Ex-/Includes specific properties from output by using the @Groups annotation (e.g. exclude $id from 'detail', but not from 'list')
- Association fields (relations to other entities) will be normalized to the ID of the entity and vice versa.
Endpoints
When you extend the RapidApiCrudController, these endpoints will become accessible automagically:
Action | HTTP Method | Example URL | HTTP Response code | HTTP Response body |
---|---|---|---|---|
Create an entity | POST | /users | 201 | Created entity |
List all entities (*) | GET | /users | 200 | Array of entities |
Find one entity | GET | /users/1 | 200 | Entity |
Update an entity | PUT | /users/1 | 200 | Updated entity |
Delete an entity | DELETE | /users/1 | 204 | - |
Find association (**) | GET | /users/1/best-friends | 200 | ToOne: A single associated entity ToMany: An array of associated entities |
Create association (**) | POST | /users/1/best-friends/2 | 201 | Entity |
Delete association (**) | DELETE | /users/1/best-friends/2 | 204 | - |
(*) These endpoints accepts some query parameters.
(**) These endpoints work for ToOne and ToMany associations. best-friends
is the name of the association on the User model: $bestFriends
.
Filtering
There are several implementations for filtering. You can change the filter mode using the ControllerConfig
.
Filter | Example |
---|---|
Basic | /users?name=Steve |
Extended | /users?filter=name:eq:Steve OR age:gt:21 |
DQL (Doctrine Query Language) | /users?filter=entity.name = 'Steve' |
Sorting
You can also add sorting to your result: /users?sort=age ASC
Pagination
You can also add paging queries: /users?page=1&limit=10
Associated entities
Associated entities are normalized to their ID by default for performance reasons.
If you want to include the entire entity you can use a query param with (comma separated) association names. For example:
On the list endpoint: /users?include=bestFriends
On the detail endpoint: /users/1?include=bestFriends
On an assocation endpoint: /users/1/best-friends?include=car
This will only go 1 deep.
How to use
The fast/flexible way
- Create an entity and implement the RapidApiCrudEntity (optionally use Symfony validation annotations)
- Create a controller that extends the RapidApiCrudController
- Implement the required method(s) and use the config DTO to enable/disable certain routes
The fully customizable way
- Create or edit an existing model and implement the RapidApiCrudEntity interface
- Create or edit an existing controller and don't extend the RapidApiCrudController
- Inject the CrudService
- Create the desired methods/routes and use the logic from CrudService to be up and running super fast
Feel free to use the ControllerFacade for specific route functionality. If you need even more specific logic, use the CrudService.
Roadmap
Take a look at our kanban board here
Support
Hey 👋 If you like our libraries. Support us by buying us a coffee!
All versions of rapid-api-crud with dependencies
symfony/serializer Version ^5.2
symfony/property-access Version ^5.2
symfony/http-foundation Version ^5.2
symfony/validator Version ^5.2
doctrine/orm Version ^2.8
symfony/framework-bundle Version ^5.2
symfony/messenger Version ^5.2
symfony/routing Version ^5.2
symfony/http-kernel Version ^5.2
lydic-group/filtering Version ^0.1.0
symfony/string Version ^5.2