PHPackages                             mosaiqo/optimus-prime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mosaiqo/optimus-prime

ActiveLibrary[API Development](/categories/api)

mosaiqo/optimus-prime
=====================

A simple package to transform collection and entities to output to a JSON / API.

3.1.0(10y ago)157PHPPHP &gt;=5.4.0

Since Sep 2Pushed 10y ago2 watchersCompare

[ Source](https://github.com/mosaiqo/optimus-prime)[ Packagist](https://packagist.org/packages/mosaiqo/optimus-prime)[ RSS](/packages/mosaiqo-optimus-prime/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (6)Versions (23)Used By (0)

Mosaiqo Optimus Prime
=====================

[](#mosaiqo-optimus-prime)

Is a simple package to transform collection and entities TO a JSON - API before the response is returned to the requester. Think of it like the view presenter so you can adjust your output before, and maintain a clean API even if you change the DDBB structure.

[![Optimus Prime](https://camo.githubusercontent.com/0b6bfe109fb94e7bea43763e4e406f1b6aadb8cc6260b330dbd8cc91c0f05550/687474703a2f2f332e62702e626c6f6773706f742e636f6d2f2d7349574776364c5a4868772f54673945396346384537492f41414141414141414464512f634c5841494155635652552f733332302f67312b6f7074696d75732b7072696d652b666163655f393932303030323231312d30332e6a7067)](https://camo.githubusercontent.com/0b6bfe109fb94e7bea43763e4e406f1b6aadb8cc6260b330dbd8cc91c0f05550/687474703a2f2f332e62702e626c6f6773706f742e636f6d2f2d7349574776364c5a4868772f54673945396346384537492f41414141414141414464512f634c5841494155635652552f733332302f67312b6f7074696d75732b7072696d652b666163655f393932303030323231312d30332e6a7067)

Instalation
-----------

[](#instalation)

---

To install Mosaiqo Optimus Prime is really simple just install it with composer:

```
	composer require mosaiqo/optimus-prime "dev-master"

```

after it just put this line in your laravel app/config.php file :

```
	'Mosaiqo\OptimusPrime\TransformerServiceProvider',

```

now you can begin to play with your transformers.

How to transform your API
-------------------------

[](#how-to-transform-your-api)

---

It's really easy to use Optimus Prime transformer.
In the model you want to use a transformer just have to implement the `Mosaiqo\OptimusPrime\Decepticons`interface. this interface forces you to use some methods to determine the transformer class.
But we have made it easy for you just pull in the `Mosaiqo\OptimusPrime\Transformable` trait we have created.

```
