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

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

lighthouse/view
===============

PHP Template Engine for the Lighthouse framework

v0.1.0(6mo ago)0111MITPHPPHP ^8.2CI passing

Since Dec 17Pushed 6mo agoCompare

[ Source](https://github.com/RichardTrujilloTorres/view)[ Packagist](https://packagist.org/packages/lighthouse/view)[ RSS](/packages/lighthouse-view/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (2)Used By (1)

Lighthouse View
===============

[](#lighthouse-view)

A simple, powerful PHP template engine for the Lighthouse framework.

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

[](#installation)

```
composer require lighthouse/view
```

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

[](#requirements)

- PHP 8.2 or higher

Features
--------

[](#features)

- PHP-based templates (no new syntax to learn)
- Layouts with sections
- Partials/includes
- Automatic HTML escaping
- Global shared data
- Dot notation for view paths

Quick Start
-----------

[](#quick-start)

### Basic Rendering

[](#basic-rendering)

```
use Lighthouse\View\View;

$view = new View('/path/to/views');

// Render a view
echo $view->render('welcome', ['name' => 'John']);
```

**views/welcome.php:**

```
Hello, !
```

### Escaping

[](#escaping)

Always escape user data to prevent XSS attacks:

```
// In templates, use $view->e() or $view->escape()

// For JSON (e.g., in JavaScript)

    var data = ;

```

### Layouts

[](#layouts)

Create a layout template:

**views/layouts/main.php:**

```
DOCTYPE html>
