chubbyphp/chubbyphp-api-slim-skeleton

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

dev-master 2018-10-10 17:05 UTC

This package is auto-updated.

Last update: 2020-09-22 18:46:36 UTC


README

DEPRECATED use https://github.com/chubbyphp/petstore

chubbyphp/chubbyphp-api-slim-skeleton

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality Code Coverage

Description

A slim 3 skeleton to build web apis.

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

{
    "_links": {
        "self": {
            "href": "/api",
            "method": "GET"
        },
        "courses": {
            "href": "/api/courses",
            "method": "GET"
        }
    },
    "_type": "index"
}

Xml

GET http://chubbyphp-api-slim-skeleton.dev/api

<?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

_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

{
    "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

<?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

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