Download the PHP package russbalabanov/tiny-rest without Composer
On this page you can find all versions of the php package russbalabanov/tiny-rest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tiny-rest
Tiny-rest
Heyyy! I just released this library and currently writing some docs for it, so please wait a while.
But if you are eager and cannot wait:
Installation
Configuration
Please modify your services.yaml
file to register this two services
Transfer Objects
Transfer object is a tiny wrapper for HTTP request. The transfer object SHOULD NOT contain entities or convert some user data into complex custom objects. The general idea is having a validatable object which will contain pure user data
Annotation
Property
name
- By default the name equals to the name of the property but can be changed for the cases when there is manual mapping needed
mapped
- whether the value will be set to Transfer object or not. Default: true
type
- There are cases when the value should be casted to a certain type, for example using Transfer Object as filter in a repository. This types are available for type cast: string
, integer
, float
, array
, datetime
, boolean
. Default value is string
Mapping
The annotation should be used for describing the transfer strategy with the entity. By default the column name equals to the name of the property.
The annotation cannot be used without @Property()
annotation
column
- By default the name equals to the name of the property but can be changed for the cases when there is manual mapping needed
mapped
- Can be set as false for cases when the property should not transfer it's data to the entity. Default: true
Relation
The @Relation()
annotation is built for the cases when the plain value in the transfer object should be converted into relation entity.
byField
- Default: id
Events
OnObjectHydrated
Triggers after object hydration but before validation
OnObjectValid
Triggers after object validation
Usage
Create, Update, List and Pagination
The idea of all operations was to allow user to care less about the trivial and usual stuff and focus on business logic
Create
To create an entity out of request you will need only three agruments. Request object, TransferObject (as a tiny wrapper for the request) and an Entity object.
Update
The update method is almost the same as create() with one exception. If you are doing a PUT HTTP method all the ORM fields (except @Id) will be cleared
Pagination
Providers for collections
ORM
DBAL
NativeQuery
Entity
Array
Handling exceptions and sending API Errors
When you don't want to bother much with validation errors, you may want to go for this solution.
WARNING: This project is currently in aplha stage, which means minimal risk of BC does exist.
Do you like the project? Smash the star button, this will motivate me to make it even better!
All versions of tiny-rest with dependencies
pagerfanta/pagerfanta Version ^2.0
doctrine/common Version ^2.9
doctrine/dbal Version ^2.8
symfony/validator Version ^4.0|^5.0
doctrine/orm Version ^2.6
symfony/property-access Version ^4.0|^5.0
symfony/http-foundation Version ^4.0|^5.0