Download the PHP package izupet/laravel-api without Composer

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

laravel-api - example repo

This is Laravel 5.* package for developing RESTful APIs very simple and efficient. It provides validation with Laravel build-in validator with possibility of extension and some helpful model methods. It is fully customizable. It is really amazing because you can define partial responses and decrease response data significantly. All other features like ordering, searching, filtering are also provided.

Prerequisite

PHP version >= 5.5
Laravel framework 5 and up

Installation

First you need to install this package using composer

Add service provider in app.php file:

After composer finishes its work, run this artisan command to generate config file

In this api.php config file you can set default limit, offset, etc.

You are done. Package is installed and successfully set up and ready for use.

Usage

To create new resource use Laravel build-in artisan command

To create CarsRequest validation class run

This will create new file in app/Http/Requests folder. In controller you can then use this CarsRequest as follows

This $request variable will be already fully equiped with validated user input. Using $request->all() will return validated and structured user input ready for further processing. As you can see, ApiResponse trait is used in this controller also. This trait is meant to be used everywhere you need to return response (controllers, exception handlers, etc.). Three main methods are there ready to be called:

  1. respondCollection($data) for collections - usually used with GET medhod
  2. respondOne($data) for single objects - usualy used with PUT or POST methods
  3. respond($message, $HTTPStatusCode, $data = null, array $extras = []) - main respond method for custom responses

All responses has meta propery which has alway present status, message and code properties. Status is generated automaticaly according to code (success or error). If response is successful, data property is added to response otherwise skipped.

Example of respondCollection response:

Example of respondOne response:

Example of respond error response:

Anytime suppressResponseHttpStatusCode param is present in query string response will be returned with status code 200. This is comes handy sometines when dealing with special applications. The code in response meta propery remains nonsuppressed.

The most powerful thing of this library are validation request classes as we created earlier (see above). Each class comes with four main methods:

Example of getRules method filled with all available helper rules:

So rules for GET method are set, let's dig in.

After validation you can access your validated request in controller. Let see how it looks request if we do dd($request->all());

All params are fine strucured and prepared to be used in services/repositories. For that purpose there are a couple of helpful methods that can be used in connection with Eloquent.

Example of repository using this methods:

Calling

is equal to

Second parameter is for retrieving total number of records matching filter criteria.

Helpers for create, update and delete:


All versions of laravel-api with dependencies

PHP Build Version
Package Version
No informations.
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 izupet/laravel-api contains the following files

Loading the files please wait ....