Skip to content

This project allows to create Posts, Categories via an interface API type

License

Notifications You must be signed in to change notification settings

120dev/template-api

Repository files navigation

Template-API

Requirements

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

Installation

  1. Clone this github repository on your local computer
$ git clone https://github.com/120dev/template-api
  1. Install dependencies
$ composer install
  1. Copy .env.sample to .env and change it's content according to your environment.
$ cp .env.sample .env
  1. Generate an application key
$ php artisan key:generate
  1. Create a databases (prod & testing) with the name used in .env (DB_DATABASE).

  2. Run the following command to create tables

$ php artisan migrate
  1. Invoke the seeder to insert some data
$ php artisan db:seed

Server

$ php artisan serve

Test

  $ phpunit

Usage / Demo

For : Create Read Update Delete on post

POST /

$ 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

GET /

$ curl -X GET http://localhost:8000/api/posts/ \
        -H 'accept: application/vnd.templateApi.v1+json' \
        -H 'cache-control: no-cache'

GET /id

$ curl -X GET http://localhost:8000/api/posts/1 \
        -H 'accept: application/vnd.templateApi.v1+json' \
        -H 'cache-control: no-cache'

PATCH /1

$ 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'

DELETE /1

$ curl -X DELETE \
    http://localhost:8000/api/posts/1 \
    -H 'accept: application/vnd.templateApi.v1+json' \
    -H 'cache-control: no-cache'

About

This project allows to create Posts, Categories via an interface API type

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages