This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

A view helper system

0.2.0 2017-12-27 17:23 UTC

This package is not auto-updated.

Last update: 2021-09-18 02:21:22 UTC



It's recommended that you use Composer to install ViewPresenter.

composer require nueve/view-presenter



$viewParser = new Nueve\ViewPresenter\PhpParser('template_directory_path');
$presentable = new Nueve\ViewParser\Presentable();
$view = new Nueve\ViewPresenter\View($viewParser, $presentable);

Now lets create a ViewPresenter.


class SitePresenter implements \Nueve\ViewPresenter\PresenterInterface
    public function data()
        return [
            'site_name' => 'Test Site',
            'site_description' => 'This is a test site to show how this works.'

We can now make use of this by setting which template it should render for.

$view->presenter('home', new SitePresenter());

Now when we render our home template the data from the presenter will be available.

$view->render('home.php', [
    'developer' => 'Some Person'

We now have access to all the properties of the SitePresenter in the home.php view file.


<p>Hi <?=$developer?></p>


Out of the box only a single Parser is provided and that is for PHP, if you would like to add another Parser, you will need to implement the ParserInterface.


The Nueve\ViewPresenter\View class takes 3 arguments, the first is the ParserInterface, the second is a PresentableInterface class and the last is a config array.

The array only contain a single property at the moment and that is the file extension property file.ext, which is by default set to .php, you should change this if you decide to use a different Parser. e.g. Twig .twig.

The presenter method on the View object takes two params, the first can be a string or a array and the second should be a PresenterInterface.


To execute the test suite, you'll need phpunit.

$ phpunit



ViewPresenter is licensed under the MIT license. See License File for more information.