PHPackages                             popcorn4dinner/presenters - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. popcorn4dinner/presenters

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

popcorn4dinner/presenters
=========================

A non-opinionated implementation of the presenter pattern

0.1.2(8y ago)05MITPHPPHP &gt;=7.1

Since Apr 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/popcorn4dinner/php-presenters)[ Packagist](https://packagist.org/packages/popcorn4dinner/presenters)[ RSS](/packages/popcorn4dinner-presenters/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Presenters
==========

[](#presenters)

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

[](#installation)

```
composer require popcorn4dinner/presenters
```

Usage
-----

[](#usage)

The idea behind presenters is to separate the presentation logic from your domain models. As a side effect you also only expose only needed functions and therefore the smallest possible interface to the render process.

### Example

[](#example)

#### Simple user and Presenter class

[](#simple-user-and-presenter-class)

```
class SimpleUser
{
    private $firstName = "Florian";
    private $lastName = "Thylman";
    private $age = 13;

    public function getFirstName()
    {
        return $this->firstName;
    }

    public function getLastName()
    {
        return $this->lastName;
    }

    public function getAge()
    {
        return $this->age;
    }

    public function setAge($newAge)
    {
        $this->age = $newAge;
    }
}
```

```
class ExamplePresenter extends AbstractPresenter
{

    protected const DELEGATED_METHODS = ['getFirstName', 'getLastName'];

    public function getFullName()
    {
        return $this->getFirstName() . ' ' . $this->getLastName();
    }

    public function getAge()
    {
        return $this->original->getAge() . ' years';
    }
}
```

#### Example usage

[](#example-usage)

Controller:

```
class UserController {
   public function view(Request $request, FindUserHandler $handler, \Twig_Environment $twig)
   {
      $command = $this->commandPopulator->populate(new FindUser(), $request);
      $user = $handler->execute($command, $user);

      $response =  new Response(
      $twig->render(
        'users/view.twig',
        [
          'user' => new UserPresenter($user)
        ]
      )
      );
      return $response;
    }
}
```

View:

```

 Name: {% $user->getFullName() %} // Florian Tylman
 Age: {% $user->getAge() %} // 13

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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 ~0 days

Total

3

Last Release

2943d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7f09c6677ed6fffa796df715c75bba02176e7329794b01059d5f73fdcec295c?d=identicon)[popcorn4dinner](/maintainers/popcorn4dinner)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/popcorn4dinner-presenters/health.svg)

```
[![Health](https://phpackages.com/badges/popcorn4dinner-presenters/health.svg)](https://phpackages.com/packages/popcorn4dinner-presenters)
```

###  Alternatives

[ideea/language-detector

Detect languages by text

334.4k](/packages/ideea-language-detector)

PHPackages © 2026

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