tardigrades / sexy-field-api
This package adds api functionality to sections.
Installs: 2 720
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 5
Open Issues: 6
Requires
- php: ^7.2
- ext-json: *
- jms/serializer: ^3.4
- symfony/config: ^4
- symfony/dependency-injection: ^4
- symfony/form: ^4
- symfony/http-foundation: ^4
Requires (Dev)
- mikey179/vfsstream: ^1.6
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0
- squizlabs/php_codesniffer: ^3.2
- tardigrades/sexy-field: dev-master
- tardigrades/sexy-field-doctrine: dev-master
- tardigrades/sexy-field-entity: dev-master
- tardigrades/sexy-field-field-types-base: dev-master
- tardigrades/sexy-field-form: dev-master
Suggests
- tardigrades/sexy-field: Without the base package this api is nothing
- tardigrades/sexy-field-doctrine: You might want to use doctrine for persisting data
- tardigrades/sexy-field-form: The api requires you to use form
- tardigrated/sexy-field-entity: You need entities, yes you do
This package is auto-updated.
Last update: 2024-11-29 05:32:39 UTC
README
SexyFieldApi
This package adds endpoints for sections to SexyField.
GET requests
Sexy-field-api is very powerful when it comes to retrieving the data that you need. Out of the box you can get all the information of your entities, including parent and child entities.
Here are some examples of how you can build your GET requests.
One recipe
/v1/section/{sectionHandle}/id/{id}
/v1/section/recipe/id/15?fields=id,title,description,recipeType,created,updated
All recipes
/v1/section/{sectionHandle}
/v1/section/recipe?fields=id,title,description,recipeType,created,updated
Recipe filtered by field value
/v1/section/fieldvalue/{sectionHandle}/{fieldHandle}
/v1/section/fieldvalue/recipe/recipeType?value=vegan&fields=id,title,description
Recipe by slug
/v1/section/{sectionHandle}/slug/{slug}
/v1/section/recipe/slug/recipe-20180325?fields=title
Recipe with ingredients (show fields of child entities as well)
The child entity is indicated by the name of the property in the parent entity.
So in this case the recipe
entity has a property called ingredients
The fields name
, amount
, unit
are properties of the ingredient.
/v1/section/recipe/id/3?fields=id,title,description,recipeType,created,updated,ingredients,name,amount,unit
POST requests
For creating a new recipe, you would have to use a POST request to:
/v1/section/recipe
Content-Type: application/x-www-form-urlencoded
Form data:
form[title]: Black bean soup
form[description]: A delicious soup
form[recipeType]: vegan
PUT, DELETE and OPTIONS requests
See src/config/routing/api.yml
Depth control for requests that return an entry
Nex to ?fields=id,field you can add &depth=3 to control the level of depth in which data is returned.