https://github.com/120dev/template-api
This project allows to create Posts, Categories via an interface API type
https://github.com/120dev/template-api
api api-server dingo laravel54 unit-testing
Last synced: 3 months ago
JSON representation
This project allows to create Posts, Categories via an interface API type
- Host: GitHub
- URL: https://github.com/120dev/template-api
- Owner: 120dev
- License: mit
- Created: 2017-05-08T03:47:53.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-08T05:57:03.000Z (about 8 years ago)
- Last Synced: 2025-01-10T01:37:24.711Z (4 months ago)
- Topics: api, api-server, dingo, laravel54, unit-testing
- Language: PHP
- Homepage:
- Size: 228 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
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
```bash
$ git clone https://github.com/120dev/template-api
```2. Install dependencies
```bash
$ composer install
```3. Copy `.env.sample` to `.env` and change it's content according to your environment.
```bash
$ cp .env.sample .env
```4. Generate an application key
```bash
$ php artisan key:generate
```5. Create a databases (prod & testing) with the name used in `.env` (`DB_DATABASE`).
6. Run the following command to create tables
```bash
$ php artisan migrate
```7. Invoke the `seeder` to insert some data
```bash
$ php artisan db:seed
```
## Server
```bash
$ php artisan serve
```
## Test```bash
$ phpunit
```## Usage / Demo
##### For : Create Read Update Delete on post#### POST `/`
```curl
$ 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
$ curl -X GET http://localhost:8000/api/posts/ \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'
```#### GET `/id`
```curl
$ curl -X GET http://localhost:8000/api/posts/1 \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'
```#### PATCH `/1`
```curl
$ 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
$ curl -X DELETE \
http://localhost:8000/api/posts/1 \
-H 'accept: application/vnd.templateApi.v1+json' \
-H 'cache-control: no-cache'
```