Download the PHP package ryannielson/prez without Composer

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

Prez

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Simple presenters for your PHP or Laravel project.

Why Should I Use Presenters?

Imagine your application has a User model. With Prez, you'd create a matching UserPresenter class. This presenter wraps the model, dealing with only presentational concerns. This keeps any view related logic out of the model, while also helping you keep logic out of the view. In your view you can use the presenter in the same way you'd use the original model. Whenever you start thinking about creating a helper function or adding logic to your view, it might be worth moving it into a presenter.

Installation

Run the following Composer command in your terminal, or simply add "ryannielson/prez": "~1.0.0" to your composer.json file:

composer require ryannielson/prez:'~1.0.0'

Once complete, if using Laravel, you now have to add the the service provider to the providers array in app/config/app.php:

'RyanNielson\Prez\PrezServiceProvider'

Usage

Creating Presenters

Presenters inherit from RyanNielson\Prez\Presenter, and should be named for the model they present. In Laravel these should live in the app/presenters directory.

Laravel Commands

Prez includes a command to automate the creation of Presenters.

To create a presenter called UserPresenter in app/presenters:

php artisan prez:presenter User

To create a presenter called UserPresenter in app/custom:

php artisan prez:presenter User --path=app/custom

Accessing the Object in a Presenter

You can access the wrapped object in a presenter by using $this->object. This allows you get get any public property or call any public function on the object.

You can also use the presents property on the presenter so that you can using a name other than $this->object to access the object. This makes the presenter code a bit more clear.

Getting a Presenter for an Object

By default, Prez assumes that your presenter class uses your object's class name followed by presenter. For example, an object with the class User is assumed to have a corresponding UserPresenter class. The presenter helper method uses this assumption to find your presenter and return an instance of it.

presenter also takes an optional class name if you want to force a specific presenter to be used.

If you prefer not to use the helper function, you can explicitily pass your object when constructing a presenter.

Using a Presenter in a View

If you have a presenter object passed to your view, you can use your presenter like any other object. The following example assumes the usage of Laravel's blade template language.

Delegating to Object

If the presenter doesn't contain a property or method, the call is delegated to the wrapped object. This makes it so that if we want to access a field on the model, we don't have to write a function in the presenter.


All versions of prez with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~5.0
illuminate/console Version ~5.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 ryannielson/prez contains the following files

Loading the files please wait ....