Download the PHP package moaalaa/laravel-api-responder without Composer

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

Api Laravel Responder

Api Responder Is A Simple Package For Api Response Using Laravel Resources With Some Features With Some Useful Readable And Chainable Methods

This Package Was Made For My Personal Usage

Prerequisites

This Package Required Laravel 5.5 (or higher)

Getting Started

Remember This Package Not Perfect It's Just Like Some Helpers For Me During Development. You Can Visit Laravel Official Docs About Api Resources For Deeper Understanding All The Rest Of The Documentation Will Explain How To Install And Every Method Provided To You

Installation

Via Composer

If You Do Not Run Laravel 5.5 (Or Higher), Then Add The Service Provider In config/app.php:

If you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider.

Usage

Using ApiResponder is Very Easy And Straights Forward Just Use ApiResponder Trait Anywhere (I Usually Use It In Controllers So The Usage And Examples Will Be Also).

Basic Usage

By Using ApiResponder Trait You Will Have Access To Method Called api() and It Will Make All The Magic For You, It Give You Access For Many Useful Methods Important One Is response() That Will Send the Response For You

Response Usage

$this->api()->response(...) Is Responsible For Responding All The Data For You And It Accepts More Than One Parameter

Parameters Desc Accepts Defaults
$data Your Data That You Want To Send Laravel Collections, Laravel Models, Laravel Pagination, Array, String, Integer, Null None But If Null Is Passed It Will Return Empty Array []
$error Error Messages String, Array, Null Null
$code The Response Status Code Integer 200
$additional Additional Data To Send With Response Array, Closure []
$wrap Wrapping Key For Returned Response String "payload"

Response Alias

Response Has An Alias Called $this->api()->responseWith() For Clear Readability

Get Paginate Limit Usage

$this->api()->getPaginateLimit() Method $this->api()->getPaginateLimit() Used To Return The Pagination Limit When Using Pagination Default Is 10 If Not Using $this->api()->setPaginateLimit($limit) To Change It.

Parameters Desc Accepts Defaults
None None None None

Set Paginate Limit Usage

$this->api()->setPaginateLimit(50)->response(...) Method $this->api()->setPaginateLimit(50) Used To Adjust The Pagination Limit When Using Pagination You Can Define It In Any Service Provider Like AppServiceProvider To Apply The Limit In All Places You Used $this->api()->getPaginationLimit() Also You Can Edit It On Runtime As Will

Parameters Desc Accepts Defaults
$limit Pagination Length ByDefault Pagination Length Is 10 Integer None

AppServiceProvider

HomeController

Error Usage

$this->api()->error(...) Is Responsible For Responding Errors Messages

Parameters Desc Accepts Defaults
$error Error Messages String, Array None
$code The Response Status Code Integer 500

Safe Error Usage

$this->api()->safeError(...) When Validation Laravel Applications And Don't Want To Use Validator Class Manually And Use $this->validate() Or request()->validate() Or $this->api()->validate() Then This Method Is For You But You Must Put Your Code In A Try Catch Block, The Method Will Handle The Exception And Get The Message Event If It's Normal Or Custom Or Even Laravel Validation Errors ( The Most Method I Love :) )

Note $this->api()->validate() Will Be Described Below

Parameters Desc Accepts Defaults
$exception Exception Variable Exception None
$code The Response Status Code Integer 500

Validate Usage

$this->api()->validate(...Roles...) It Validate The Request Inputs And Return The Validated Inputs

Note It's Just A Wrapper On request()->validate() Function

Parameters Desc Accepts Defaults
$attribute Array Of Roles For Validation Array None

With Usage

$this->api()->with(...)->response(...) This Method Is Very Useful When Sending Additional Data With The Response Or To Make The Code More Readable

Parameters Desc Accepts Defaults
$additional Array Of Additional Data Array None

You Can Also Make A Dynamic Naming

But It Still Had Some Issues Be Carful HWne Using It

Get Wrapping Usage

$this->api()->getWrapping This Method Gets The Wrapping Key String Around Your Data

Parameters Desc Accepts Defaults
None None None None

Set Wrapping Usage

Method $this->api()->setWrapping('foo') Used To Adjust The Wrapping Key String Around Data Response You Can Define It In Any Service Provider Like AppServiceProvider To Apply The New Wrapping Key String In All Places You Used $this->api()->response() Method Also You Can Edit It On Runtime As Will

Note It Have An Alias Called $this->api()->wrapping('foo')

Parameters Desc Accepts Defaults
$wrapping The Wrapping Key String Around Data Response Default Is "payload" String None

AppServiceProvider

HomeController

Example

Todo


All versions of laravel-api-responder with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8
illuminate/support Version 5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|10.*|11.*|12.*
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 moaalaa/laravel-api-responder contains the following files

Loading the files please wait ....