Skip to content

nodes-php/api

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 

API

⚠️This package is deprecated⚠️

Laravel support for REST apis are just fine now. Dingo API is not in beta anymore.

We suggest just using Laravel + spatie/laravel-fractal

A "mobile friendly" API package made on-top of the popular Dingo API package.

Total downloads Monthly downloads Latest release Open issues License Star repository on GitHub Watch repository on GitHub Fork repository on GitHub StyleCI

πŸ“ Introduction

Before this package we used the awesome and popular Dingo API package, but as a company who create a lot of native iOS / Android apps, Dingo was lacking a few things here and there.

This package is in some way a more "mobile friendly" version of Dingo. It is build on-top of Dingo so all the goodies that Dingo comes with out-of-the-box is also available here.

We simply just added extra functionality and made it more flexible.

πŸ“¦ Installation

To install this package you will need:

  • Laravel 5.1+
  • PHP 5.5.9+

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

"require": {
    "nodes/api": "^1.0"
}

Or you can run the composer require command from your terminal.

composer require nodes/api:^1.0

πŸ”§ Setup

Setup service providers in config/app.php

Nodes\Api\ServiceProvider::class,

Setup alias in config/app.php

'API' => Nodes\Api\Support\Facades\API::class,
'APIRoute' => Nodes\Api\Support\Facades\Route::class

Publish config files

php artisan vendor:publish --provider="Nodes\Api\ServiceProvider"

If you want to overwrite any existing config files use the --force parameter

php artisan vendor:publish --provider="Nodes\Api\ServiceProvider" --force

Bypass Laravel's CSRF tokens

Laravel comes with a built-in CSRF token system, which is by default hooked into all POST requests. This gives us a bit of a problem since API requests won't contain the required CSRF token that Laravel expects. Therefore we need to whitelist all requests hitting our API.

This can be done by modifying the following file app/Http/Middleware/VerifyCsrfToken.php and add api/* to the $except array:

protected $except = [
    'api/*',
];

βš™ Usage

Please refer to our extensive Wiki documentation for more infromation

πŸ† Credits

This package is developed and maintained by the PHP team at Nodes

Follow Nodes PHP on Twitter Tweet Nodes PHP

πŸ“„ License

This package is open-sourced software licensed under the MIT license