chubbyphp/chubbyphp-api-slim-skeleton
, (*1)
Description
A slim 3 skeleton to build web apis., (*2)
Requirements
Installation
composer create-project chubbyphp/chubbyphp-api-slim-skeleton myproject dev-master --prefer-dist
Setup
Create database
bin/console chubbyphp:model:dbal:database:create
Create / Update schema
bin/console chubbyphp:model:dbal:database:schema:update --dump --force
Sample Responses
Index
Json
GET http://chubbyphp-api-slim-skeleton.dev/api, (*3)
{
"_links": {
"self": {
"href": "/api",
"method": "GET"
},
"courses": {
"href": "/api/courses",
"method": "GET"
}
},
"_type": "index"
}
Xml
GET http://chubbyphp-api-slim-skeleton.dev/api, (*4)
<?xml version="1.0" encoding="UTF-8"?>
<meta-type value="index">
<meta-links>
<self>
<href type="string">/api</href>
<method type="string">GET</method>
</self>
<courses>
<href type="string">/api/courses</href>
<method type="string">GET</method>
</courses>
</meta-links>
</meta-type>
Yaml
GET http://chubbyphp-api-slim-skeleton.dev/api, (*5)
_links:
self:
href: /api
method: GET
courses:
href: /api/courses
method: GET
_type: index
Courses
Json
GET http://chubbyphp-api-slim-skeleton.dev/api/courses?page=1&perPage=1, (*6)
{
"page": 1,
"perPage": 1,
"sort": null,
"order": "asc",
"_embedded": {
"count": 1,
"pages": 1,
"courses": [
{
"id": "d480082e-ef4f-43e6-96e8-fd2b9fa613ff",
"name": "PHP Course",
"level": 3,
"progress": 0.45,
"active": true,
"documents": [
{
"id": "28031482-6168-47f1-a78b-ea57f38d0ef0",
"name": "Choose the right abstraction",
"url": "http://test.com/choose-the-right-abstractions.pdf",
"_type": "document"
}
],
"_links": {
"read": {
"href": "/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff",
"method": "GET"
},
"update": {
"href": "/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff",
"method": "PATCH"
},
"delete": {
"href": "/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff",
"method": "DELETE"
}
},
"_type": "course"
}
]
},
"_links": {
"self": {
"href": "/api/courses?page=1&perPage=1&order=asc",
"method": "GET"
},
"create": {
"href": "/api/courses",
"method": "POST"
}
},
"_type": "course-search"
}
Xml
GET http://chubbyphp-api-slim-skeleton.dev/api/courses?page=1&perPage=1, (*7)
<?xml version="1.0" encoding="UTF-8"?>
<meta-type value="course-search">
<page type="integer">1</page>
<perPage type="integer">1</perPage>
<sort></sort>
<order type="string">asc</order>
<meta-embedded>
<count type="integer">1</count>
<pages type="integer">1</pages>
<courses>
<meta-type value="course" key="0">
<id type="string">d480082e-ef4f-43e6-96e8-fd2b9fa613ff</id>
<name type="string">PHP Course</name>
<level type="integer">3</level>
<progress type="float">0.45</progress>
<active type="boolean">true</active>
<documents>
<meta-type value="document" key="0">
<id type="string">28031482-6168-47f1-a78b-ea57f38d0ef0</id>
<name type="string">Choose the right abstraction</name>
<url type="string">http://test.com/choose-the-right-abstractions.pdf</url>
</meta-type>
</documents>
<meta-links>
<read>
<href type="string">/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff</href>
<method type="string">GET</method>
</read>
<update>
<href type="string">/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff</href>
<method type="string">PATCH</method>
</update>
<delete>
<href type="string">/api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff</href>
<method type="string">DELETE</method>
</delete>
</meta-links>
</meta-type>
</courses>
</meta-embedded>
<meta-links>
<self>
<href type="string">
<![CDATA[/api/courses?page=1&perPage=1&order=asc]]>
</href>
<method type="string">GET</method>
</self>
<create>
<href type="string">/api/courses</href>
<method type="string">POST</method>
</create>
</meta-links>
</meta-type>
Yaml
GET http://chubbyphp-api-slim-skeleton.dev/api/courses?page=1&perPage=1, (*8)
page: 1
perPage: 1
sort: null
order: asc
_embedded:
count: 1
pages: 1
courses:
-
id: d480082e-ef4f-43e6-96e8-fd2b9fa613ff
name: 'PHP Course'
level: 3
progress: 0.45
active: true
documents:
-
id: 28031482-6168-47f1-a78b-ea57f38d0ef0
name: 'Choose the right abstraction'
url: 'http://test.com/choose-the-right-abstractions.pdf'
_type: document
_links:
read:
href: /api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff
method: GET
update:
href: /api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff
method: PATCH
delete:
href: /api/courses/d480082e-ef4f-43e6-96e8-fd2b9fa613ff
method: DELETE
_type: course
_links:
self:
href: '/api/courses?page=1&perPage=1&order=asc'
method: GET
create:
href: /api/courses
method: POST
_type: course-search