PHPackages                             mpphp/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. [Framework](/categories/framework)
4. /
5. mpphp/view

ActiveLibrary[Framework](/categories/framework)

mpphp/view
==========

MPPHP view library.

v1.0.0-alpha(7y ago)0442MITPHPPHP ^7.1

Since May 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mpphp/veiw)[ Packagist](https://packagist.org/packages/mpphp/view)[ Docs](https://mpphp.github.io/mpphp/)[ RSS](/packages/mpphp-view/feed)WikiDiscussions master Synced 4d ago

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

Veiw
====

[](#veiw)

MPPHP view library.

A view is the file that contains the code that gets printed on the browser period. And the MVC architecture demands that we keep our business logic away from these view files. Traditionally beginners i thought to make database calls or process their forms on the same file as the form:

```

    // Required inputs

```

This would be a bad idea because now your View now has knowledge of your backend code. Now most people at this point would say theu write their logic in a different file and include it like so:

```

    // Required inputs

```

Well technically, the two versions are the same, the view is still aware of the back end logic.

There are lots of third party Templating Engines out there like Smarty, Latte, Mustache, but most PHP frameworks come bundled with their own Templating engine, for example Symfony has Twig, Laravel has Blade and Phalcon has Volt. And MpPHP well, it just has a single file containing functions that mimic the important features of a Templating Engine like Inheritance and Sections/Blocks that we like to call VIEW.

Defining A Layout
-----------------

[](#defining-a-layout)

Two of the primary benefits of using a templating engine are template inheritance and sections. To get started, let's take a look at a simple example. First, we will examine a "master" page layout. Since most web applications maintain the same general layout across various pages, it's convenient to define this layout as a single Blade view:

```

        App Name -

```

As you can see, this file contains typical HTML mark-up. However, take note of the \_view\_\_nest() and the \_view\_\_include() functions. The \_view\_\_include function, as the name implies, includes a template, while the \_view\_\_nest() function is used to display the contents of a given section.

Now that we have defined a layout for our application, let's define a child page that inherits the layout.

Extending A Layout
------------------

[](#extending-a-layout)

When defining a child vtemplate, use the \_view\_\_extends() function to specify which layout the child template should "inherit". Templates which extend a layout may inject content into the parent template by wrapping its content in a function with the same name passed into it's parents \_view\_\_nest() function. Remember, as seen in the example above, the contents of these sections will be displayed in the layout \_view\_\_nest('content'):

```

    Child Page

    This is my body content.

```

`From this section down, we would be talking about best practices for using PHP in a view or a template file.`

Displaying Data
---------------

[](#displaying-data)

To display a PHP value to the browser, we would use `echo` or `print` but if the only thing your doing withing a PHP opening an closing tag is an `echo` or `print` you can use the shorthand version like so:

```

```

Much simpler than:

```
 or

```

Dont you think?

Control Structures
------------------

[](#control-structures)

It is common for young developers to mix their view with business logic in a way that makes it impossible for a front end developer who has little knowledge of PHP to work with their projects, for example it is comon to find a view that has the following code:

```

```

This would be easier for any front end personel to work on your project without having to worry about PHP, I mean it's there but they can easily be ignored compared to the previous version.

This step would work for both Control structures and logical expressions likewise.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

2571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/267c0ebc19a68dd31263dab46f2d5224ac2e1ff1af6fb62e4417c8817f419667?d=identicon)[tsommie](/maintainers/tsommie)

---

Top Contributors

[![tsommie](https://avatars.githubusercontent.com/u/10388658?v=4)](https://github.com/tsommie "tsommie (9 commits)")

---

Tags

phpframeworkviewproceduralMpPHP

### Embed Badge

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

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

###  Alternatives

[slim/php-view

Render PHP view scripts into a PSR-7 Response object.

2739.7M95](/packages/slim-php-view)

PHPackages © 2026

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