Download the PHP package lewis/presenter without Composer

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

A view presenter is an incredibly useful way of decorating objects bound to your views. This allows you to perform view related logic in a sensible place instead of placing it directly in your views, or worse, your models.

There are several other libraries out their that provide similar functionality. This package is merely my preferred implementation as everything is configured in isolation to the object being decorated.

Install

You can install this package using Composer:

Or in your composer.json:

Once you've run composer update you'll need to register the service provider in your config/app.php file.

Usage

Configuring Presenters

There's several ways to configure your presenters. First, you can utilize the configuration file, which can be published using the following command:

There are no presenters configured by default. The published file merely contains an explanation on how to configure your presenters. You must provide an array of key/value pairs linking your object to its presenter.

If you'd prefer you can set an array of presenters directly on the decorator. You might choose do to this from a service provider.

Lastly, you can configure presenters one at a time using the register method, again, from within a provider.

Creating Presenters

A presenter should extend from Lewis\Presenter\AbstractPresenter, however, it is NOT required, but highly recommended, as you'll have access to several methods and magic methods that provide some useful functionality.

I like to keep my presenters within a Presenters folder, however, you may organize things in whichever way you prefer.

If you wish to inject dependencies the only requirements are that you name a parameter $object so that Laravel can correctly inject the bound object and that you call the parent constructor.

Your presenter can then define methods to perform logic that can be used in your views.

You can reference properties on the wrapped object directly (as above), or by using the $object property.

From Within Views

Now that you've configured your presenters and created them, you just need to use them from within your views. It's a simple matter of calling the method or property as you define it.

You can also still access you relations and other model attributes.

Enjoy

That's about all there is to it.


All versions of presenter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
illuminate/support Version 5.1.*|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 lewis/presenter contains the following files

Loading the files please wait ....