PHPackages                             touhidurabir/laravel-presenter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. touhidurabir/laravel-presenter

ActiveLibrary[Templating &amp; Views](/categories/templating)

touhidurabir/laravel-presenter
==============================

A package that helps to group methods that mostly use for the view presentation purpose.

1.0.1(4y ago)9171MITPHPPHP &gt;=7.3

Since Oct 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/touhidurabir/laravel-presenter)[ Packagist](https://packagist.org/packages/touhidurabir/laravel-presenter)[ RSS](/packages/touhidurabir-laravel-presenter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel Presenter
=================

[](#laravel-presenter)

A package that helps to group methods that mostly use for the view presentation purpose.

Installation
------------

[](#installation)

Require the package using composer:

```
composer require touhidurabir/laravel-presenter
```

To publish the config file:

```
php artisan vendor:publish --provider="Touhidurabir\Presenter\PresenterServiceProvider" --tag=config
```

Configurations
--------------

[](#configurations)

Check the published config file for the details of configurations options.

Usage
-----

[](#usage)

First step is to generate a presenter class . To make this process easy, this package comes with a command that helps to generate the presenter classes. To generate the presenter class via command, do as

```
php artisan make:presenter PresenterClassName
```

For example :

```
php artisan make:presenter UserPresenter
```

will generate a **UserPresenter** at the **App\\Presenters** namespaced path.

it will have following content

```
namespace Touhidurabir\Presenter\Tests\App\Presenters;

use Touhidurabir\Presenter\BasePresenter;

class UserPresenter extends BasePresenter {

}
```

Now to use this with the combination of **User** model class, drop the **HasPresenter** trait and defined property **$presenter** as :

```
use Illuminate\Database\Eloquent\Model;
use Touhidurabir\Presenter\HasPresenter;
use Touhidurabir\Presenter\Tests\App\Presenters\UserPresenter;

class User extends Model {

    use HasPresenter;

    protected $presenter = UserPresenter::class;
}
```

Now to define a method in our presenter class, follow as :

```
class UserPresenter extends BasePresenter {

    public function someMethod() {

        return $this->model->some_presentable_data;
    }
}
```

And Now any **public** method defined in the **UserPresenter** class can be accesses as :

```
$user->present()->someMethod
```

> It is also possible to not define the **$presenter** property while using the presenter class for models . In that case it will try to resolve the presenter through the model name and default store namespace defined in the **config** file .
>
> For example, by default it will try to find a class in the **App\\Presenters** location with name of **UserPresenter** for **User** model if the **$presenter** property not set in the **User model**. If it can find it, then it will use that for **User** model presenter . If none found, it will throw exception.

It is also possible to set/update the presenter on fly . To do that , need to user the **setPresenter** method defined in the **HasPresenter** trait as :

```
$user->setPresenter(UserPresenter::class);
$user->present()->anyMethodDefinedInPresenter;
```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](./LICENSE.md)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Total

2

Last Release

1638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c6009d764c48df4a55a8645c349f90a99c7e6e694b06c60b580e1da278d1db5?d=identicon)[touhidurabir](/maintainers/touhidurabir)

---

Top Contributors

[![touhidurabir](https://avatars.githubusercontent.com/u/2587979?v=4)](https://github.com/touhidurabir "touhidurabir (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/touhidurabir-laravel-presenter/health.svg)

```
[![Health](https://phpackages.com/badges/touhidurabir-laravel-presenter/health.svg)](https://phpackages.com/packages/touhidurabir-laravel-presenter)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
