PHP code example of neilrussell6 / laravel5-json-api
1. Go to this page and download the library: Download neilrussell6/laravel5-json-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
neilrussell6 / laravel5-json-api example snippets
'providers' => [
...
\Neilrussell6\Laravel5JsonApi\Providers\Laravel5JsonApiServiceProvider::class,
...
'aliases' => [
...
'JsonApiUtils' => \Neilrussell6\Laravel5JsonApi\Facades\JsonApiUtils::class
...
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
// App\Exceptions\Handler::class
\Neilrussell6\Laravel5JsonApi\Exceptions\Handler::class
);
protected $routeMiddleware = [
...
'jsonapi' => \Neilrussell6\Laravel5JsonApi\Http\Middleware\JsonApi::class,
...
Route::group(['middleware' => ['jsonapi'], 'namespace' => 'Api'], function () {
...
class Controller extends JsonApiController
...
protected $model;
...
public function __construct ($model)
{
$this->model = new $model();
...
...
'connections' => [
...
'mysql' => [
...
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
...
Response::item
Response::collection
Response::pagination
protected $routeMiddleware = [
...
'jsonapi.jwt' => \Neilrussell6\Laravel5JsonApi\Http\Middleware\TransformJWTResponse::class,
...
Route::group(['middleware' => ['jsonapi.jwt']], function () {
...
'acl' => [
...
'seeder_config' => 'laratrust_seeder'
'permissions_map' => [
'i' => 'index',
'c' => 'store',
'r' => 'show',
'u' => 'update',
'd' => 'destroy',
]
'role_structure' => [
'administrator' => [
'projects' => 'i,c,r,u,d',
'projects.owner' => 'r',
'projects.relationship.owner' => 'r',
'projects.tasks' => 'i',
'acl' => [
'use_role_hierarchy' => true,
'role_hierarchy' => [ // higher overrides lower
'super_administrator' => 4,
'administrator' => 3,
'editor' => 2,
'moderator' => 2,
'subscriber' => 1,
]
'hierarchical_roles' => [
'super_administrator',
'administrator',
'editor'
],
$this->call(JsonApiAclSeeder::class);
bash
php artisan migrate --path=packages/neilrussell6/laravel5-json-api/src-testing/database/migrations
bash
php artisan migrate --path=vendor/neilrussell6/laravel5-json-api/src-testing/database/migrations
bash
php artisan serve
bash
touch database/laravel5_json_api_testing.sqlite
sudo chmod -R 777 database/laravel5_json_api_testing.sqlite
bash
php artisan migrate --path=packages/neilrussell6/laravel5-json-api/src-testing/database/migrations --database=sqlite_testing
bash
php artisan migrate --path=vendor/neilrussell6/laravel5-json-api/src-testing/database/migrations --database=sqlite_testing
bash
php artisan serve
bash
php artisan route:list