Download the PHP package erikgall/transformer without Composer

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

Laravel Model Transformer

Transform Laravel Eloquent models into an array of specified keys with the option of including nested relationships as their transformed model array.

The Reason

This package was created to ease complexity, simplify model's, while allowing for them to be quickly transposed into an array of specified keys.

But turning an eloquent model into an array is easy right? You only have to call the toArray() method. The shortfall comes when you want the final array to only have specific fields/keys, as well as a nested relationship. You end up transforming the model inside of your controller, specifying each and every key and value the array should have.

Example

Without Laravel Model Transformer

With Laravel Model Transformer

And it returns:

Getting Started

These instructions will get you get you up and running and using the package inside of your Laravel application.

Prerequisities

The package was developed using Laravel 5.2 and PHP 7 so there may be incompatibilities with PHP 5.

Installing

To install the package inside of your Laravel app, please follow the steps below.

Step 1: Run the following command from your project root.

Step 2: Add the package's service provider to your provider's array in you app.php config file.

Step 3: Create a transformers directory inside of the directory where your model files live. Example using the location of a User model and its transformer class:

- app/User.php -> app/transformers/UserTransformer.php
- app/Models/User.php -> app/models/transformers/UserTransformer.php

* The Transformers directory must be in the same directory as you models... Only if you wish to use the automatic transformer class finder. Otherwise you must specify the model's transformer class/full namespace.

Step 4: Any models use wish to use a transformer with must implement the EGALL\Transformer\Contracts\Transformable interface/contract. You should also include the trait EGALL\Transformer\Traits\TransformableModel inside of your model classes.

Example below:

User Model Transformer Class

Using the User Model Transformer from a controller.

Running the tests

Install the package and install it's dependencies. After, that is complete and once inside the package's root, run the following command:

Built With/Using

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details


All versions of transformer with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ^5.2
illuminate/database Version ^5.2
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 erikgall/transformer contains the following files

Loading the files please wait ....