Download the PHP package swisnl/json-api-server without Composer

On this page you can find all versions of the php package swisnl/json-api-server. 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 json-api-server

Latest Version on Packagist Build Status License: MIT Made by SWIS

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

We don't use this package anymore in our own projects and there are many, better alternatives, so that's why we have chosen to abandon it. We suggest using laravel-json-api/laravel or one of the other alternatives instead. Feel free to fork our code and maintain your own copy.

Laravel JSON API server

Set up a laravel API in just a few minutes with this package. All the standard API functionality is already there for you.

This package strives to save you some time while building your API. It already has the basic features an API should have, like:

Install

Via Composer

Sample

Please see the folder sample for a sample of an application using this package.

Usage

Base Api Classes

There are a few base classes your classes should/could inherit:

BaseApiController

This controller handles your basic CRUD actions as well as permissions if you choose to use permissions.

BaseApiRepository

This repository is a standard base repository with a small addition that it figures out your models relationships.

If you want to use your own BaseRepository, you have to implement the RepositoryInterface. This ensures that you have full compatibility with the BaseApiController.

The BaseApiRepository uses a trait to retrieve a models relationships. You can use this trait if you want to use the existing implementation.

Generating the required files

After installing the package you can instantly generate all the required files by executing this command:

To override the default path without overriding the laravel_generator config file, you can use the --path={path} option. For example:

This generates the following files:

You'll be able to do the basic CRUD actions without writing anything.

You also have the ability to generate the files separately:

Configuration

If you would like to override the configuration files.

If you decide to override the templates, make sure you override the laravel api config too. You have to define where your own templates are in the config.

This is the default configuration:

Requests and responses

All requests and responses are formatted according to the format specified by http://jsonapi.org/.

There are several respond methods at your disposal in your controller. The following respond methods are implemented at this moment:

These methods automatically converts your objects to json api format and creates a response with the correct status code and body.

Using policies

If you decide to use policies to check for the user's pemissions you have to add the policies to your Providers\AuthServiceProvider.

The policies are preconfigured to work with Laravel passport, if you want to use another form of authorizing actions you can change the methods.

If you want to redirect the validation to a specific function in your policy.

If you want to check if they can request a specific object you can add that object as the second parameter:

URL parameters out of the box

The following URL parameters are supported after installing this package:

Mandatory middleware

Optional middleware

There is optional middleware:

Passport installation

Note: if you want to know more about laravel passport and why these commands should be run go to https://laravel.com/docs/passport

After running this command, add the Laravel\Passport\HasApiTokens trait to your App\User model

Next, you should call the Passport::routes method within the boot method of your AuthServiceProvider.

Finally, in your config/auth.php configuration file, you should set the driver option of the api authentication guard to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests.

If you created your own routes make sure you have the auth:api middlware on all the routes you want to use passport with.

Packages Laravel-Api uses

Laravel framework
Astrotomic / laravel-translatable

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

SWIS

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.


All versions of json-api-server with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2|^8.0
ext-json Version *
astrotomic/laravel-translatable Version ^11.6
laravel/framework Version ^6.0|^7.0|^8.0|^9.0
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 swisnl/json-api-server contains the following files

Loading the files please wait ....