PHPackages                             darkstar/view - 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. darkstar/view

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

darkstar/view
=============

Provides an implementation of the TemplateView and TwoStepView patterns, with support for helpers and for closures as templates, using PHP itself as the templating language.

v1.0.0(5y ago)0231BSD-2-ClausePHPPHP &gt;=7.2.0

Since Nov 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/darkstarphp/darkstar.view)[ Packagist](https://packagist.org/packages/darkstar/view)[ Docs](https://github.com/elevenone/View)[ RSS](/packages/darkstar-view/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (1)

This is a fork from Aura View Changed for php 7.x

Aura View
=========

[](#aura-view)

This package provides an implementation of the [TemplateView](http://martinfowler.com/eaaCatalog/templateView.html) and [TwoStepView](http://martinfowler.com/eaaCatalog/twoStepView.html) patterns using PHP itself as the templating language. It supports both file-based and closure-based templates along with helpers and sections.

It is preceded by systems such as [`Savant`](http://phpsavant.com), [`Zend_View`](http://framework.zend.com/manual/en/zend.view.html), and [`Solar_View`](http://solarphp.com/class/Solar_View).

Foreword
--------

[](#foreword)

### Installation

[](#installation)

This library requires PHP 5.4 or later; we recommend using the latest available version of PHP as a matter of principle. It has no userland dependencies.

It is installable and autoloadable via Composer as [aura/view](https://packagist.org/packages/aura/view).

Alternatively, [download a release](https://github.com/auraphp/Aura.View/releases) or clone this repository, then require or include its *autoload.php* file.

### Quality

[](#quality)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d4f9c893a05b3037984344f2b3a607222ec83b0326f5edd8f1fd8103a4f8c367/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f617572617068702f417572612e566965772f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f702d32)](https://scrutinizer-ci.com/g/auraphp/Aura.View/)[![Code Coverage](https://camo.githubusercontent.com/8c03dc8fc4dd0ed99179b5edf63c6d110469fca530a6dcea9c0bc156a07f65b9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f617572617068702f417572612e566965772f6261646765732f636f7665726167652e706e673f623d646576656c6f702d32)](https://scrutinizer-ci.com/g/auraphp/Aura.View/)[![Build Status](https://camo.githubusercontent.com/68fa3e78bc642747596b006f1cc928283bc7142565c95cc95d755a89137bb363/68747470733a2f2f7472617669732d63692e6f72672f617572617068702f417572612e566965772e706e673f6272616e63683d646576656c6f702d32)](https://travis-ci.org/auraphp/Aura.View)

To run the unit tests at the command line, issue `composer install` and then `./vendor/bin/phpunit` at the package root. This requires [Composer](http://getcomposer.org/) to be available as `composer`.

This library attempts to comply with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), and [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md). If you notice compliance oversights, please send a patch via pull request.

### Community

[](#community)

To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our [Google Group](http://groups.google.com/group/auraphp), follow [@auraphp on Twitter](http://twitter.com/auraphp), or chat with us on #auraphp on Freenode.

Getting Started
---------------

[](#getting-started)

### Instantiation

[](#instantiation)

To instantiate a *View* object, use the *ViewFactory*:

```

```

### Escaping Output

[](#escaping-output)

Security-minded observers will note that all the examples in this document use manually-escaped output. Because this package is not specific to any particular media type, it **does not** come with escaping functionality.

When you generate output via templates, you **must** escape it appropriately for security purposes. This means that HTML templates should use HTML escaping, CSS templates should use CSS escaping, XML templates should use XML escaping, PDF templates should use PDF escaping, RTF templates should use RTF escaping, and so on.

For a good set of HTML escapers, please consider [Aura.Html](https://github.com/auraphp/Aura.Html#escaping).

### Registering View Templates

[](#registering-view-templates)

Now that we have a *View*, we need to add named templates to its view template registry. These are typically PHP file paths, but [templates can also be closures](#closures-as-templates). For example:

```
