PHPackages                             pyrech/layout - 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. pyrech/layout

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

pyrech/layout
=============

Provides a wrapper to render HTML layout with doctype, meta, styles, scripts, etc

0192PHP

Since Dec 20Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Pyrech/Layout-PHP)[ Packagist](https://packagist.org/packages/pyrech/layout)[ RSS](/packages/pyrech-layout/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Layout-PHP
==========

[](#layout-php)

Don't handle the HTML doctype, meta, title, style, script, etc yourself, use **Pyrech\\Layout**.

Layout is a PHP class that wrap and render an HTML Layout. You can customize the doctype, meta, stylesheet, scripts, etc.

The class can be used in two ways. You can either specify your settings in the render method or add each element in head section in the order you want.

\[RECOMMENDED\] First way (add each element as you want):
---------------------------------------------------------

[](#recommended-first-way-add-each-element-as-you-want)

```
$content = 'Hello World';

$layout = \Pyrech\Layout::getInstance(); // Or new \Pyrech\Layout();

$layout->setDoctype(\Pyrech\Layout::DOCTYPE_HTML5)
       ->addMeta('charset', 'utf-8')
       ->addTitle('My wonderful title')
       ->addMeta('description', 'Description of your page')
       ->addMeta('robot', 'index')
       ->addMeta('http-equiv:refresh', '60') // If the key attribute is not 'name', prefix the value by the attribute then ':''
       ->addIcon('/favicon.png', 'png')
       ->addIcon('/favicon.ico', 'ico')
       ->addStyle('/my-stylesheet.css') // Default media is 'all'
       ->addStyle('/print.css', 'print')
       ->addScript('/my-javascript.js', \Pyrech\Layout::SCRIPT_DEFER)
       ->addScript('alert("Hello World!");', \Pyrech\Layout::SCRIPT_INTERNAL)
       ->addBodyClass(array('some-class', 'another-class')); // Array of classes or a string with several classes

echo $layout->render($content);

```

Second way (via render method):
-------------------------------

[](#second-way-via-render-method)

```
$content = 'Hello World';

$layout = \Pyrech\Layout::getInstance(); // Or new \Pyrech\Layout();

$opts = array('doctype' => \Pyrech\Layout::DOCTYPE_HTML5,
              'meta'    => array('charset'            => 'utf-8',
                                 'description'        => 'Description of your page',
                                 'robot'              => 'index',
                                 'http-equiv:refresh' => '60'), // If the attribute is not name, prefix the value by the attribute then ':'
              'title'   => 'My wonderful title',
              'icon'    => array('/favicon.png' => 'png',
                                 '/favicon.ico' => 'ico'),
              'styles'  => array('/my-stylesheet.css', // Default media is 'all'
                                 '/print.css' => 'print'),
              'scripts' => array('/my-javascript.js', // Defer can be setted for one script with the \Pyrech\Layout::SCRIPT_DEFER option
                                 'alert("Hello World!");' => \Pyrech\Layout::SCRIPT_INTERNAL),
              'defer'   => true, // Defer can be setted for all scripts
              'class'   => array('some-class', 'another-class')); // Array of classes or a string with several classes

echo $layout->render($content, $opts);

```

Custom elements
---------------

[](#custom-elements)

If you want to insert a custom element in the head part, you must use the first way (see above) and call the addElement method :

```
$layout->addElement('');

```

Pyrech\\Layout can be implemented in any PHP framework or can be used in a simple structure. Available via composer : [pyrech/layout](https://packagist.org/packages/pyrech/layout)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

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.

### Community

Maintainers

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

---

Top Contributors

[![pyrech](https://avatars.githubusercontent.com/u/2021641?v=4)](https://github.com/pyrech "pyrech (24 commits)")

### Embed Badge

![Health badge](/badges/pyrech-layout/health.svg)

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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