All Projects → cloudcreativity → Demo Laravel Json Api

cloudcreativity / Demo Laravel Json Api

Demo of JSON API integration with a Laravel Application

Projects that are alternatives of or similar to Demo Laravel Json Api

Api Generator
PHP-code generator for Laravel framework, with complete support of JSON-API data format
Stars: ✭ 244 (+258.82%)
Mutual labels:  json-api, laravel
Sarala
Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent
Stars: ✭ 101 (+48.53%)
Mutual labels:  json-api, laravel
Laravel Api Boilerplate
A Boilerplate Project For Laravel API's (NOT MAINTAINED)
Stars: ✭ 113 (+66.18%)
Mutual labels:  json-api, laravel
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (+360.29%)
Mutual labels:  json-api, laravel
Polr
🚡 A modern, powerful, and robust URL shortener
Stars: ✭ 4,147 (+5998.53%)
Mutual labels:  json-api, laravel
Laravel Json Api
JSON API (jsonapi.org) package for Laravel applications.
Stars: ✭ 667 (+880.88%)
Mutual labels:  json-api, laravel
Aimeos Laravel
Laravel ecommerce package for professional, ultra fast online shops, complex B2B applications and #gigacommerce
Stars: ✭ 5,204 (+7552.94%)
Mutual labels:  json-api, laravel
Laravel Jsonapi
Basic setup framework for creating a Laravel JSON-API server
Stars: ✭ 16 (-76.47%)
Mutual labels:  json-api, laravel
Prequel
Prequel for Laravel. Clear and concise database management.
Stars: ✭ 1,141 (+1577.94%)
Mutual labels:  laravel
Laravel Remember Uploads
Laravel Middleware and helper for remembering file uploads during validation redirects
Stars: ✭ 67 (-1.47%)
Mutual labels:  laravel
Sinoci
中国特色化 CodeIgniter
Stars: ✭ 66 (-2.94%)
Mutual labels:  laravel
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-2.94%)
Mutual labels:  laravel
Dreamfactory
DreamFactory API Management Platform
Stars: ✭ 1,148 (+1588.24%)
Mutual labels:  laravel
Groups
A Laravel 5 user groups package
Stars: ✭ 66 (-2.94%)
Mutual labels:  laravel
Laravel Ecommerce
AvoRed an Open Source Laravel Shopping Cart
Stars: ✭ 1,151 (+1592.65%)
Mutual labels:  laravel
Laravel Tinymce Simple Imageupload
Simple image upload for TinyMCE in Laravel.
Stars: ✭ 66 (-2.94%)
Mutual labels:  laravel
Laravel Vue Tasks
📝 Task app built with Laravel 5.5 and Vue 2
Stars: ✭ 66 (-2.94%)
Mutual labels:  laravel
Videosniffer
视频嗅探服务(VideoSniffer API Service On Android)
Stars: ✭ 68 (+0%)
Mutual labels:  json-api
Chat Demo
Demo Application for https://github.com/musonza/chat/
Stars: ✭ 67 (-1.47%)
Mutual labels:  laravel
Nova Advanced Image Field
🌄📐 A Laravel Nova advanced image field with cropping and resizing using Cropper.js and Intervention Image
Stars: ✭ 67 (-1.47%)
Mutual labels:  laravel

Laravel JSON API Demo

This application demonstrates how to use the cloudcreativity/laravel-json-api package to create a JSON API compliant API. This is demonstrated using Eloquent models as the domain records that are serialized in the API, but the package is not Eloquent specific.

Setup

The application uses Homestead, so you'll need Vagrant installed on your local machine.

Once you've cloned this repository, change into the project folder then:

composer install
cp .env.example .env
php vendor/bin/homestead make
vagrant up

Remember you'll need to add an entry for homestead.app in your /etc/hosts file.

Once it is up and running, go to the following address in your browser to see the JSON endpoints:

http://homestead.app/api/v1/posts

To access the web interface:

http://homestead.app

If you use the Vagrant hosts updater plugin, the hostname may be demo-laravel-json-api or similar.

Authentication

Any write requests require an authenticated user. We've installed Laravel Passport for API authentication. You will need to use Personal Access Tokens and the Vagrant provisioning runs the Passport installation command.

To create a token, go to the web interface and login (the username and password fields are completed with credentials that will sign you in successfully). You'll then see the Passport Person Access Token component which you can use to issue tokens.

Once you have a token, send a request as follows, replacing the <api_token> with your token.

POST http://homestead.app/api/v1/posts
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Authorization: Bearer <api_token>

{
    "data": {
        "type": "posts",
        "attributes": {
            "slug": "hello-world",
            "title": "Hello World",
            "content": "..."
        }
    }
}

Eloquent vs Not-Eloquent

This package can handle both Eloquent and non-Eloquent records. You get a lot more functionality out of the box if you are using Eloquent, but it's possible to integrate non-Eloquent records as needed.

This demo includes the following JSON-API resources:

Resource Record Eloquent?
comments App\Comment Yes
posts App\Post Yes
sites App\Site No
tags App\Tag Yes
users App\User Yes

Tests

We're big on testing, and the cloudcreativity/laravel-json-api package comes with test helpers to make integration testing a JSON API a breeze. You can see this in action in the tests/Integration folder, where there's a test case for the posts resource.

To run the tests:

vendor/bin/phpunit
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].