Download the PHP package davidianbonner/presenter without Composer

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

Presenter/Transformer

Build Status StyleCI

A simple data presenter/transformer for Laravel applications that can be used with views and JSON.

In most cases, the data transformation required to output JSON via a REST API is the same as the data required in our views. This package prevents having to use transformers for JSON (i.e. with Fractal – great for larger apps and complex transformations) and attribute mutators. Whether returning a view or JSON, the data can be presented and transformed using the one class.

Installation

Install the package through Composer:

Laravel 5.5+ uses Package Auto-Discovery which doesn't require you to manually add the ServiceProvider. However if you are using 5.4 or earlier, add the package service provider in the providers array in config/app.php:

Add the facade to your aliases in `config/app.php:

Then publish the config file:

How it works

A 'transformation' will only take place if the object implements the Presentable interface.

If the presentable object is an eloquent model, the presenter will check for loaded relationships and attempt to transform them as well, replacing the existing relationship with the transformer object.

Present/transform an object

When transformed, the object will injected into a transformer class which will give you access to magic methods, magic getters on the object and automatic toArray and toJson output.

Pre-set transformers

Set your presentable => transformer relations in config/presenter.php:

Transformers

Transformers must extend DavidIanBonner\Presenter\Transformer. A transformer can utilise mutated attribute methods in a similar manner to eloquent.

Response macros

To simplify your code and prevent having to repeat Present::transform() for all objects, there are two handy macros available that will handle this automatically.

Views

A helper method is also available for convenience that will sites above the view helper.

JSON

JSON transformation is handled a little differently from views. Response::json() checks if an object implements Illuminate\Contracts\Support\Jsonable, if it does, it calls toJson on that object. The toJson method of the base transformer will call toArray and json_encode it. toArray will attempt to collect the keys from the Presentable object passed to it and attempt to get each of these keys on the transformer which will in turn call any magic methods etc.

Collection macro

A collection macro is available to loop over an arrayable set of items and transform any presentable objects.

Contributing

Contributions are welcome! Please read CONTRIBUTING for details.

Copyright and license

The davidianbonner/presenter library is copyright © David Bonner and licensed for use under the MIT License (MIT). Please see LICENSE for more information.


All versions of presenter with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
illuminate/contracts Version ^6.0
illuminate/support Version ^6.0
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 davidianbonner/presenter contains the following files

Loading the files please wait ....