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

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

hydrakit/view
=============

Native PHP templating for the Hydra PHP framework

v0.2.0(yesterday)016↑25%2MITPHP &gt;=8.2

Since Jul 6Compare

[ Source](https://github.com/hydra-foundation/view)[ Packagist](https://packagist.org/packages/hydrakit/view)[ RSS](/packages/hydrakit-view/feed)WikiDiscussions Synced today

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

Hydra View
==========

[](#hydra-view)

Native PHP templating — no compilation step, no new syntax, no cache directory. A template is a plain `.php` file; the engine gives it Twig-style inheritance and escape-by-convention safety while staying ordinary PHP you can read top to bottom.

The seam
--------

[](#the-seam)

Controllers depend on `Contracts\ViewInterface`, never on the engine, so the template engine is an application choice — bind a Twig adapter in its place and no controller changes. The shipped implementation is `PhpView`.

```
use Hydra\View\PhpView;

$view = new PhpView(__DIR__ . '/views');
echo $view->render('home', ['name' => 'Will']);
```

Inside a template
-----------------

[](#inside-a-template)

The `$this` a template sees is a per-render `Template`, so nested partials and layout chains never stomp each other's state. The vocabulary:

- `$this->e($value)` — escape for HTML. Escaping is **by convention, not by default**: templates are ordinary PHP, so a bare `` emits raw output — always route dynamic values through `e()`. Within `e()`, every value is treated as untrusted; the *only* way to emit raw markup through it is to wrap the value in `HtmlView`, so forgetting the `HtmlView` mark can only ever over-escape. Forgetting `e()` itself, however, under-escapes — that discipline is on the template author.
- `$this->extends('layouts/base')` — wrap this template in a layout. The child's leftover output becomes the layout's `content` section. Chains to any depth.
- `$this->start('title') … $this->stop()` / `$this->section('title', $default)` — capture and yield named sections.
- `$this->partial('card', [...])` — render another template inline as its own independent chain (inherits none of the parent's data; a stray `extends()`inside is ignored).
- `$this->siteUrl('/blog')` — build an absolute URL for canonical / Open Graph tags (see below).
- `$this->csrf()` / `$this->csrfToken()` — emit the session CSRF token (see below).

Full page vs. htmx fragment, one template
-----------------------------------------

[](#full-page-vs-htmx-fragment-one-template)

`render($t, $data, layout: false)` returns the template's own body and ignores its `extends()`. That's how a single template serves both a full page (layout on) and an htmx fragment (layout off) off one route — the inheritance is resolved by output buffering, so the fragment path simply doesn't walk the chain.

CSRF (optional)
---------------

[](#csrf-optional)

`PhpView`'s second argument is an optional `Hydra\Csrf\CsrfGuard`. Wired, the template can emit `$this->csrf()` (a hidden `_token` field) and `$this->csrfToken()`(the raw token, for a `` tag or htmx `hx-headers`). Left null — the isolation default — the csrf helpers throw if a template calls them, but the rest of the engine works untouched.

Absolute URLs (optional)
------------------------

[](#absolute-urls-optional)

`PhpView`'s third argument is an optional base URL string (the app passes its configured site URL). With it, `siteUrl('/blog')` → `https://example.com/blog` and `siteUrl()` → the bare origin. It's a plain string, not an app config object, so this package stays free of any application's config types. Absent it, `siteUrl()` returns the path unchanged.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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 ~1 days

Total

3

Last Release

1d ago

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

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