Download the PHP package neilrussell6/laravel5-json-api without Composer

On this page you can find all versions of the php package neilrussell6/laravel5-json-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel5-json-api

Laravel 5 JSON API

Response format:

Usage

Use composer to require packages

Update config/app.php

Update bootstrap/app.php

Update app/Http/Kernel.php

Update routes/api.php

Extend JsonApiController

eg. if your API will use app/Http/Controllers/Controller.php asa base controller, then update as follows:

Manual testing

NOTE: if you are using MySQL < 5.7.7 then update the character set in config/database.php as follows:

eg. in laravel/5.4.x:

1) Configure database in laravel/5.4.x/.env

2) Run migrations

or if using in a project where this package was required via composer:

3) Seed database with sample data

4) Serve project

5) View in Postman

eg. GET http://127.0.0.1:8000/api eg. GET http://127.0.0.1:8000/api/users eg. GET http://127.0.0.1:8000/api/users/1

Running automated tests

TODO: create an artisan command to automate all this.

Assuming the following directory structure:

1) Create a symlink from packages to laravel/5.4.x/packages. Repeat for other versions and Lumen.

2) Copy env.testing.example to env.testing

3) Copy everything in src-testing (excluding database directory) into cleaning install (laravel/5.4.x)

4) Update each clean install's composer.json:

4) Create a testing DB in each clean install (in laravel/5.4.x) and make it executable:

5) add the following to .env for each clean install (laravel/5.4.x/.env)

6) Run migrations (in laravel/5.4.x)

or if using in a project where this package was required via composer:

7) Update Codeception config before each separate version test

eg. for laravel/5.4.x, update to root property in the following files:

as follows:

8) Serve project (for Acceptance tests)

eg. in laravel/5.4.x/

9) Run tests (in packages/neilrussell6/laravel5-json-api)

Customisation

You can customize request/response handling by overriding Controller methods

2 helpful tools for customisation are:

1) The package's utility facade Neilrussell6\Laravel5JsonApi\Facades\JsonApiUtils

2) The package's Response macros, eg.

see src/Providers/Laravel5JsonApiServiceProvider.php for implementation.

Road Map

JSON API

License

MIT

JWTAuth

This package provides support for usage with JWTAuth

Middleware

This package includes middleware that will transform JWTAuth error responses to conform with JSON API specs.

Update app/Http/Kernel.php

Update routes/api.php

Add 'jsonapi/jwt' middleware to your routes eg.

NOTE: This middleware will also work with any package that returns single error strings. eg. [ 'error' => 'some error' ]

Configuration

config/jsonapi.php

You can configure how error messages are returned by adjusting the JWTAuth mappings in:

The keys of keyed arrays must correspond with JWTAuth error codes which are:

ACL

This package provides support for usage with Laratrust. But the ACL handling is implemented in such a way that it should work with most ACL packages or native Laravel policies/gates, but some configuration may be required.

Configuration

config/jsonapi.php

You can configure what authorisation checks are called, and how they are called by configuring the following:

You can also configure how ACL related error messages are returned by adjusting the following:

The keys of keyed arrays must correspond with the following:

This package also comes with a JsonApiAclSeeder, which should be used instead of LaratrustSeeder.php By default JsonApiAclSeeder will look for role, permission structures and maps in config/laratrust_seeder.php but you can define the location of your ACL structure by setting jsonapi.acl.seeder_config in config/jsonapi.php, just make sure your ACL's data structure is the same as that of Laratrust.

When configuration your ACL structure make sure the permissions map follows laravel's route action naming convention eg.

Also make sure the module part of your role_structure is a valid laravel route name, eg.

For a list of all the routes in your project use the following command:

Role Hierarchy

This package includes optional support for role hierarchies, meaning that if set, a role can override the ownership check for roles with a lower hierarchy than it. eg. if a role called admin has a hierarchy of 3 and a role called subscriber has a hierarchy of 1, then a user with the admin role can perform actions (for which it has permission) on records belonging to users with the subscriber role.

To use role hierarchy, update config/jsonapi.php as follows:

Then when creating roles set the hierarchy & is_hierarchical values.

You can alternatively setup roles using the JsonApiAclSeeder seeder, which can be configured as follows:

First define the order of your hierarchy in config/jsonapi_acl_seeder.php, eg.

Then specify which roles will be hierarchical (by default roles will not be hierarchical)

return [ 'role_structure' => [ 'hierarchical_roles' => [ 'administrator' ],

The above setup will mean that:

Then run the JsonApiAclSeeder, eg. Add the following to the run method of your database/seeds/DatabaseSeeder.php file:

This seeder will setup all your roles and permissions data, including role hierarchies according to the configurations detailed above, but will not create any users.

Remember don't run both the LaratrustSeeder and the JsonApiAclSeeder.


All versions of laravel5-json-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.4
laravel/framework Version 5.4.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package neilrussell6/laravel5-json-api contains the following files

Loading the files please wait ....