Download the PHP package vinelab/api-manager without Composer

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

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Scrutinizer Code Quality

API Manager

A simple API response formatter and handler for Laravel. Beautify and unify your responses with the least effort possible.

Install

Via composer:

Add the service provider to the providers array in app/config/app.php:

Configuration

Publish the package config file:

It is now located at app/config/packages/vinelab/api-manager/api.php

Namespace

The mappers is where you specify your mappers base namespace (See Mappers Terminology for more on mappers)

You may use Api::setMapperNamespace('\New\Namespace\\'); to override the configured namespace.

Limit

The limit is where you set the maximum number of data to be returned with any endpoint request.

Setup

This package expects to have Mapper class for each model you want to return via the API.

Mappers

A Mapper is a class that transforms any supported data type (i.e. Model) into a suitable array for an API response with the attributes of your choice.

By default the Api Manager will call the method map on the given mapper unless indicated differently by passing [$mapper, $method] where $mapper is either the actual instance of the class name as a string.

Example:

Mapper Class

Mapper Usage

Mapper Examples

Here are some examples implementing a mapper called PostsMapper

Array Mapping

Model Mapping

Usage and Responses

From your controller you can use the Api Facade Class that contains these 2 important functions respond and error.

Data Types

The Api::respond($mapper, $data) accepts the following data types for $data

The responses returned by this package follows the conventions of a json api and the standards recommended by the book Build APIs You Won't Hate.

When $total and $page are null they won't be included in the response.

Pagination

Response

Model

Response

Collection

Response

Request Data Limit

Part of the api is the limit you would like to enforce on the clients that request your API. To make it easier and more centralized you may use the Api to set and get the limit value, aso configure a ceiling (max) value which cannot be exceeded by the requesting client.

The value is read from the limit query parameter. i.e. http://api.com/?limit=20

To get the requested limit use Api::limit() which will automatically verify that the requested limit does not exceed your maximum specified limit value.

To override the limit value (configured limit) within your code you can use Api::setLimit(100).

Error Handling

For an error response use the Api::error function.

$exception can be either a string (the exception message) or an inheritance of either Exception or RuntimeException

Erorr with Exception

  • 401 will be the HTTP response code
  • 1001 is the error code (specific to the API)
Response

Error with Message

Response

Contributing

Please see CONTRIBUTING for details.

License

The package is open-sourced software licensed under the MIT license.


All versions of api-manager with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.*
illuminate/config Version 5.*
illuminate/http Version 5.*
illuminate/routing Version 5.*
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 vinelab/api-manager contains the following files

Loading the files please wait ....