This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel like approach to View Presenters

2.2.0 2019-08-28 13:05 UTC

This package is auto-updated.

Last update: 2020-02-28 14:46:08 UTC


Build Status PHP from Packagist Latest Version License

The Problem

A lot of times nowadays we are working with dozens of third-party packages and not all of those offer an easy way of replacing models used by them. This means it can become quite a task to extend or replace those if you would like to use something like a Presenter on these. This package tries to solve this issue by registering presenters like Laravel does with Policies to allow binding any Presenter to any model so you don't need to replace third-party models.



Require this package, with Composer, in the root directory of your project.

$ composer require artisanry/presenter-registrar


Register presenters via PresenterServiceProvider


namespace App\Providers;

use Artisanry\PresenterRegistrar\PresenterRegistrarServiceProvider as ServiceProvider;

class PresenterServiceProvider extends ServiceProvider
    protected $presenters = [
        'App\User' => 'App\Presenters\UserPresenter',
        'ThirdParty\Models\Model' => 'App\Presenters\ThirdPartyPresenter',

Create the previously registered presenter


namespace App\Presenters;

use Artisanry\PresenterRegistrar\Presenter;

class UserPresenter extends Presenter
    public function fullName()
        return "{$this->model->firstName} {$this->model->lastName}";

Use presenter from anywhere (usually inside a view)

{{ present($user)->fullName }}


$ phpunit


If you discover a security vulnerability within this package, please send an e-mail to All security vulnerabilities will be promptly addressed.


This project exists thanks to all the people who contribute.


Mozilla Public License Version 2.0 (MPL-2.0).