Download the PHP package deozza/philarmony-core-bundle without Composer
On this page you can find all versions of the php package deozza/philarmony-core-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deozza/philarmony-core-bundle
More information about deozza/philarmony-core-bundle
Files in deozza/philarmony-core-bundle
Package philarmony-core-bundle
Short Description A bundle to create quickly a modular REST API upon Symfony 4
License MIT
Informations about the package philarmony-core-bundle
Philarmony
Table of contents
- About
- Installation
- Configuration
- Example of usage
- How it works
- Tests
- Road map
About
Philarmony is a bundle made to help you create a modular REST API. From database to controllers and forms, without forgetting authorization and data validation, manage your API easily in minutes.
V.3.0 - What's new ?
Better performances, this is what can resume Philarmony V3. The core has been rewritten with
Installation
You can install using composer, assuming it is already installed globally :
composer require deozza/philarmony-core-bundle
Configuration
In order yo use Philarmony in your project, you need to configure it. First, create a philarmony.yaml
file with the following structure :
This will be used to locate the database schema files. By default they are created and stored in /var/Philarmony/
.
Then, to use the embedded services, as the controllers and the repositories, of Philarmony, you need to enable them in your /config/services.yaml
and in your config/routes/annotations.yaml
:
Finally, in order to use filters inside your query, add the following functions inside the doctrine.yaml
configuration file :
Example of usage
For this example, our API example will manage vacation rentals. Users are able to create rental offers, book vacations and communicate through an internal message service.
Therefore, the database would be constituted with 4 different entity kinds :
offer
: contains all the infos about a rental offerbooking
: contains all the info about a booking and the offer it is linked withconversation
: contains all the message of a conversation between 2 usersmessage
: contains the content of the message and other informations about it
These entities are defined by default inside the entity.yaml
configuration file, and their properties inside the property.yaml
file.
Here is an example of a cUrl request with its body (in JSON) to create a new rental offer :
As you can see, the kind of entity you post is specified in the url. This will allow Philarmony to adapt the comportment of the API following the logic you implemented in the yaml
configuration files and via your business logic. Here is the JSON response you would expect from the previous request:
Say that an offer can have multiple descriptions and you want to add another one, simply send a request like the following :
Here will be the expected response :
Responses
Response code | Raised by | Details |
---|---|---|
200 | The request is successful | More |
201 | The post request is successful | More |
204 | The request is successful and the response has an empty body | More |
400 | Form error assertion | More |
403 | User is not allowed to perform this request | More |
404 | The resource requested was not found | More |
405 | The method used is not allowed on the route requested | More |
409 | The request is successful but the data submitted is not valid | More |
When you perform a request to Philarmony, it will always send a response containing a serialized JSON and one of the HTTP code listed above.
How it works
Database schema
Your database schema is fully designed by 3 yaml files.
Entity
An Entity is what could be view as a MySQL table, a main container of data. By default, it is defined by an owner (the User who created the entity), a kind, the date it was create and its properties.
- Read more
Property
The property is what could be view as a MySQL column, the container of a specific data. By default, it is defined by a type, a unique
paremeter and a required
parameter.
- Read more
Enumeration
The enumeration is a list of possible values handled by of property.
- Read more
Validation state
Validation state is used in order to assert an entity is in good conditions to be used. Each state defines specific methods usable by specific users.
- Read more
Authorization
To assure the right user is manipulating a resource, authorization is handled by the validation state. It determines which users are allowed to send the different requests.
- Read more
Constraints
In order to pass from one state to the next, the entity and its data must be valid according to constraints.
- Read more
Conflict rules
A conflict rules is a custom and advanced constraint that need to be developed and cannot be added to a configuration file.
- Read more
Tests
A demo app has been developped and is visible here. Through the tests of this app, we ensure that every feature of Philarmony is tested and we garanty the stability of the bundle.
Road map
- Database migration : for now, when you delete or update a property or an entity, you need to handle manually the migration. For a better experience, I am thinking about a kind of automatic solution
All versions of philarmony-core-bundle with dependencies
ext-ctype Version *
ext-iconv Version *
alcaeus/mongo-php-adapter Version ^1.1
deozza/philarmony-utils Version ^3.0
deozza/response-maker-bundle Version ^1.0
doctrine/mongodb-odm-bundle Version ^3.5
jms/serializer-bundle Version ^3.2
nelmio/cors-bundle Version ^1.5
ramsey/uuid-doctrine Version ^1.5
scienta/doctrine-json-functions Version ^4.0
symfony/dotenv Version 4.2.* || 4.3.*
symfony/flex Version ^1.1
symfony/form Version 4.2.* || 4.3.*
symfony/orm-pack Version ^1.0
symfony/translation Version 4.2.* || 4.3.*
symfony/validator Version 4.2.* || 4.3.*
symfony/yaml Version 4.2.* || 4.3.*