Download the PHP package mmanos/laravel-api without Composer

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

RESTful API package for Laravel 5

This is an API package for the Laravel framework. It allows you to build a flexible RESTful API that can be consumed externally and by your own application.

Installation

Composer

Add this to you composer.json file, in the require object:

After that, run composer install to install the package.

Service Provider

Register the Mmanos\Api\ApiServiceProvider in your app configuration file.

Class Alias

Add a class alias to app/config/app.php, within the aliases array.

Laravel 4

Use the 1.0 branch or the v1.* tags for Laravel 4 support.

Configuration

Publish config files and migrations

Publish the lucadegasperi/oauth2-server-laravel config file and migrations to your application.

Edit the published config file to fit your authentication needs. See this configuration options page for information.

Publish the mmanos/laravel-api config file and migrations to your application.

And then run the migrations.

Add the following line to your app/Http/Kernel.php file in the $middleware array to catch any OAuth error and respond appropriately:

In order to make some the authorization and resource server work correctly with Laravel 5, remove the App\Http\Middleware\VerifyCsrfToken line from the $middleware array and place it in the $routeMiddleware array like this: 'csrf' => 'App\Http\Middleware\VerifyCsrfToken',.

Note: remember to add the csrf middleware manually on any route where it's appropriate.

Handling Exceptions

We need to modify the exception handler to properly format exceptions thrown by this package. Update the App/Exceptions/Handler.php file to use the exception handler from this package.

Then add the Mmanos\Api\Exceptions\HttpException exception class to the $dontReport array so regular HTTP Exceptions are not reported.

Controllers

Configuration

Add the ControllerTrait to each of your API controllers. You could optionally add this to a BaseController extended by all of your other controllers.

Pagination

If you return a pagination object from your controller action this package will add the following headers to the response:

Setting custom response headers

You may access the response object and set any additional headers directly from your controller action:

Errors

Dealing with errors when building your API is easy. Simply use the Api::abort method to throw an exception that will be formatted in a useful manner.

Throw a 404 Not Found error:

Or a 403 Access Denied error:

Customize the error message:

Pass the errors from a validation object to get a clean response with all validation errors:

Protecting your API endpoints

You may use the protect route filter to ensure the request is authenticated:

Or you may call the Api::protect() method directly.

If this check fails, a call to Api::abort(401) is made resulting in an Unauthorized error response.

Checking scope access

Use the checkscope route filter to ensure the requested resource is accessible:

Or you may call the Api::checkScope('users:write') method directly.

If this check fails, a call to Api::abort(403) is made resulting in an Access Denied error response with the scope name.

Transforming output

Any model, collection, or pagination object returned by your controller action will be automatically sent through any bound transformer classes.

Transformers

Transformers allow you to easily and consistently transform objects into an array. By using a transformer you can type-cast integers, type-cast booleans, and nest relationships.

Bind a class to a transformer

Set a class property

Alternatively, you could add a transformer property to your class to be auto-recognized by this package:

Creating a transformer class

Ensure your transformer class has a transform static method:

Internal Requests

A big part of this package is being able to perform requests on your API internally. This allows you to build your application on top of a consumable API.

Performing requests

Use the Api::internal() method to initiate an internal request:

Passing extra parameters

Specify HTTP method

CORS Support

CORS support is enabled by default, but only if the Origin header is detected. Adjust the settings in the config file to control the behavior and header values.


All versions of laravel-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
illuminate/support Version ~5.0
lucadegasperi/oauth2-server-laravel Version 4.0.x
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 mmanos/laravel-api contains the following files

Loading the files please wait ....