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

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

anax/view
=========

Anax View module, collect and render views.

v2.0.18(5y ago)019.4k↓90%2[1 PRs](https://github.com/canax/view/pulls)20MITPHPPHP ^7.2CI failing

Since Mar 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/canax/view)[ Packagist](https://packagist.org/packages/anax/view)[ Docs](https://dbwebb.se/anax)[ RSS](/packages/anax-view/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (67)Used By (20)

Anax View
=========

[](#anax-view)

[![Latest Stable Version](https://camo.githubusercontent.com/18ca9a61542f63c9a4fc3f51f21cc9cab7a7e957d67258d152d410d89f897165/68747470733a2f2f706f7365722e707567782e6f72672f616e61782f766965772f762f737461626c65)](https://packagist.org/packages/anax/view)[![Join the chat at https://gitter.im/mosbth/anax](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/canax?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://camo.githubusercontent.com/87ac99b7433bb5d7251c5719f7773839cad7ec992814e006b191fe9dfc659909/68747470733a2f2f7472617669732d63692e6f72672f63616e61782f766965772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/canax/view)[![CircleCI](https://camo.githubusercontent.com/fdb366e6fb295c13679d39c75d7f03f98e003448617643f0deffd339e679e297/68747470733a2f2f636972636c6563692e636f6d2f67682f63616e61782f766965772e7376673f7374796c653d737667)](https://circleci.com/gh/canax/view)

[![Build Status](https://camo.githubusercontent.com/aadf055750d3b86fc8a20e050113f308b8a5230bd3449d56fd045f57f0840ffe/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f766965772f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/view/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/906d94a54e9b661ad60e1c154aa3e0a9b36668735c01c56a67deb9a2c17af18e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f766965772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/view/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/8936543e28f213066e87963050d121791399c4803b353b7aa2af0dfd23d8d5ec/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f766965772f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/view/?branch=master)

[![Maintainability](https://camo.githubusercontent.com/68c20ce8e82d50d9cffd965981fba4ec0aa8e6ae7a966981d5075bf73ef6a4e9/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62316232613566346239336261346336333065342f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/canax/view/maintainability)[![Codacy Badge](https://camo.githubusercontent.com/cf419d4d0f878a7aa70cc9e5cae885282f5c1aa37a78ee87769132ac8f56686b/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6135356266346333383932653461653739613138636538366464356530353037)](https://www.codacy.com/app/mosbth/view?utm_source=github.com&utm_medium=referral&utm_content=canax/view&utm_campaign=Badge_Grade)

Anax View module to supply a structure of views to a Anax website.

About views, terminology and structure
--------------------------------------

[](#about-views-terminology-and-structure)

The views, also known as template files, are pure PHP files and their purpose is to render content onto a html structure to create a web page.

It works like this:

1. The content of the webpage is gathered as a collection of views.
2. The view collection is created in the router callbacks and controllers.
3. A view is a combination of variables (content), commonly known as `$data`, which is supplied to a template file, which is executed and renders the data onto a html structure.
4. Each view is a small part of html and content and rendered onto the web page.

You can see a sample of views in the directory [`view/anax/v2`](view/anax/v2).

Views are rendered in a layout
------------------------------

[](#views-are-rendered-in-a-layout)

The views are rendered in an orderd fashion by a structured layout. This layout is in itself a view (template file and data), it is just a view which renders more views.

You can see a sample of an layout view in [`view/anax/v2/layout`](view/anax/v2/layout).

The layout views you above have organised each part of the web page as regions. Each view is rendered in a region.

This code shows how a general region is setup in the layout file, and how it renders the views belonging to this region.

```

```

You can optionally add a region, and a sort value, when you add the views to the collection. This is what decides where (region), and in what order the view is rendered.

A template file for the view
----------------------------

[](#a-template-file-for-the-view)

A template file is an ordinary PHP-file. Here is the template file [`anax/v2/article/default`](view/anax/v2/article/default.php).

```
>

```

The namespace makes it possible to access a list of built in view helper functions, for example helper functions to escape output or create urls into the framework or assets.

```
namespace Anax\View;
```

The commented section can be uncommented for debugging what helper functions and what variables that are available.

```
// Show incoming variables and view helper functions
//echo showEnvironment(get_defined_vars(), get_defined_functions());
```

The general idea is then to further prepare content through incoming variables.

```
// Prepare classes
$classes[] = "article";
if (isset($class)) {
    $classes[] = $class;
}
```

Then finally render the output.

```
>

```

That is the general procedures of a template file.

View helpers
------------

[](#view-helpers)

The file [`View/ViewHelperFunctions`](src/View/ViewHelperFunctions.php) holds the helper functions that eases work in the template files.

Here are some essential helpers.

FunctionDetails`asset($url)`Create a link to a static asset (css, img, php-file, pdf).`e($str)`A shortcut for `htmlentities().`url($url)`Create an url within the framework, for example `""` (home route) or `"doc/about"`.`redirect($url)`Redirect to another url (within the framework), for example `"game/init"`.Review the helper files for details.

Dumb views or fat views
-----------------------

[](#dumb-views-or-fat-views)

A view can be "dumb" and only recive input from the framework, and render it with the html code.

A view can also be "fat", or perhaps not so "smart", and make calls back into the framework.

The general recomendation is to have dumb views and not make calls back into the framwork.

Type of views
-------------

[](#type-of-views)

A view can generally render any type of result and is not limited to html only.

License
-------

[](#license)

This software carries a MIT license. See [LICENSE.txt](LICENSE.txt) for details.

```
 .
..:  Copyright (c) 2013 - 2019 Mikael Roos, mos@dbwebb.se

```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% 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 ~21 days

Recently: every ~14 days

Total

66

Last Release

1993d ago

Major Versions

v1.0.26 → v2.0.0-alpha.12018-08-01

PHP version history (2 changes)v1.0.0PHP &gt;=5.6

v2.0.0-alpha.1PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cac244120f54c02a4fb3186b91323f3f0805dd9daefd0babeb4a82a19232faf?d=identicon)[mikael\_roos](/maintainers/mikael_roos)

---

Top Contributors

[![mosbth](https://avatars.githubusercontent.com/u/169550?v=4)](https://github.com/mosbth "mosbth (130 commits)")[![marcusgsta](https://avatars.githubusercontent.com/u/20501360?v=4)](https://github.com/marcusgsta "marcusgsta (1 commits)")

---

Tags

templateanax

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anax-view/health.svg)

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

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.6k37.4M220](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

418145.2M55](/packages/rize-uri-template)[mopa/bootstrap-sandbox-bundle

Seperate live docs from code

246.8k](/packages/mopa-bootstrap-sandbox-bundle)[larablocks/pigeon

A more flexible email message builder for Laravel 5 including chained methods, reusable message configurations, and message layout and template view management.

143.7k](/packages/larablocks-pigeon)

PHPackages © 2026

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