This project allows to create posts, categories via an interface API type
The following dependencies needs to be previously installed :
- PHP 5.6
- Laravel 5.4
- Composer
- Clone this github repository on your local computer
$ git clone https://github.com/120dev/template-api
- Install dependencies
$ composer install
- Copy
.env.sample
to.env
and change it's content according to your environment.
$ cp .env.sample .env
- Generate an application key
$ php artisan key:generate
-
Create a databases (prod & testing) with the name used in
.env
(DB_DATABASE
). -
Run the following command to create tables
$ php artisan migrate
- Invoke the
seeder
to insert some data
$ php artisan db:seed
$ php artisan serve
$ phpunit
$ curl -X POST \
http://localhost:8000/api/posts/ \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache' \
-F title=test \
-F body=body \
-F active=1 \
-F category_id=1
$ curl -X GET http://localhost:8000/api/posts/ \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'
$ curl -X GET http://localhost:8000/api/posts/1 \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'
$ curl -X PATCH \
http://localhost:8000/api/posts/1 \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'title=title&body=body&category_id=1&active=1'
$ curl -X DELETE \
http://localhost:8000/api/posts/1 \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'