Download the PHP package thomzee/laramap without Composer
On this page you can find all versions of the php package thomzee/laramap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laramap
Laramap
Introduction
Every laravel API projects need a map to avoid get lost in the response jungle. Laramap is a Laravel package for object or array mapping in order to give a mature REST API response easier and cleaner.
Installation
You can choose one of those two installation methods freely.
1. Automatic Installation
Go into your project root folder laravel
then get the latest version of Laramap on your project with following command.
2. Manual Installation
Alternatively, you can update your composer.json file, just like code below
b. then run composer install
command.
Register Service
Firstly you need register the service provider your project configuration file config/app.php
and the facade as well in same file.
Run composer dump-autoload
command to update changes in your project configuration file.
Mapper Class Generator
Make sure is exist, and list artisan command with
then generate a mapper file with artisan command, example:
Update the content of single() method. The array keys is attributes of the response and $item is a representation of single object or array, example:
Features
Import the package in above of your controller class.
That's it. That is because you has registered the package in your project configuration file.
1. Paginated Data
Get list of paginated data with pages information.
First parameter must be Mapper class you generated before and the second must be instance of Illuminate\Contracts\Pagination\Paginator
.
You can do where clause and other query builder functions before finally you call the paginate() function here.
the code above, using Mapper the one we create earlier which is class, and the result is like this
2. Single Data
Get single object or array. You can even fill it with a Laravel collection
and the result is like this
3. List Data
Get list data (array data) without paginate the items, with this example code
and the result is something like this.
4. Success Response
Response success meta, with no parameters.
4. Error Response
or and error meta.
5. Response For Validation
Response Laravel Validation errors bag
the result is
License
This package is open-sourced software licensed under the MIT license.
All versions of laramap with dependencies
illuminate/support Version 5.x|6.x|7.x|8.x
illuminate/contracts Version 5.x|6.x|7.x|8.x
illuminate/http Version 5.x|6.x|7.x|8.x
illuminate/database Version 5.x|6.x|7.x|8.x