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

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

lukman-ss/view
==============

A lightweight PHP view renderer with file lookup, namespaced views, sections, layouts, partials, and escaping helpers.

v1.0.2(1mo ago)1109↓50%1MITPHPPHP &gt;=8.2

Since Jun 14Pushed 1w agoCompare

[ Source](https://github.com/lukman-ss/view)[ Packagist](https://packagist.org/packages/lukman-ss/view)[ Docs](https://github.com/lukman-ss/view)[ RSS](/packages/lukman-ss-view/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (5)Dependencies (1)Versions (4)Used By (1)

Lukman View (`lukman-ss/view`)
==============================

[](#lukman-view-lukman-ssview)

[![Lukman View Hero Image](docs/hero.png)](docs/hero.png)

A lightweight PHP view renderer with file lookup, namespaced views, layouts, sections, partials, and escaping helpers.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2

Installation
------------

[](#installation)

```
composer require lukman-ss/view
```

Usage
-----

[](#usage)

```
use Lukman\View\FileViewFinder;
use Lukman\View\PhpEngine;
use Lukman\View\ViewFactory;

$finder = new FileViewFinder([__DIR__ . '/views']);
$engine = new PhpEngine();
$view = new ViewFactory($finder, $engine);

echo $view->render('home', ['name' => 'Lukman']);
```

`views/home.php`:

```
Hello,
```

View Names
----------

[](#view-names)

Dot notation maps to paths:

```
echo $view->render('pages.home');
```

This resolves `views/pages/home.php`.

Namespaced views:

```
$finder->addNamespace('admin', __DIR__ . '/views/admin');

echo $view->render('admin::dashboard.index');
```

Shared Data
-----------

[](#shared-data)

```
$view->share('appName', 'Demo');
$view->share(['locale' => 'en']);

echo $view->render('home', ['appName' => 'Override']);
```

Render data overrides shared data.

Layouts and Sections
--------------------

[](#layouts-and-sections)

`views/layouts/app.php`:

```
