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

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

memran/marwa-view
=================

A modern Twig-powered view layer for PHP 8.2+ with fragment caching, theme inheritance, and framework-agnostic DX.

v1.0.0(3mo ago)09441MITPHPPHP ^8.2CI passing

Since Apr 2Pushed 3mo agoCompare

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

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

Marwa\\View
===========

[](#marwaview)

[![Packagist Version](https://camo.githubusercontent.com/b3e230ff0006efcb5c4369e9c47b30c99868546ad17f99e86ba51e21bf2a2a41/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656d72616e2f6d617277612d766965772e737667)](https://packagist.org/packages/memran/marwa-view)[![Packagist Downloads](https://camo.githubusercontent.com/2ab17b47141fcf3bef681c1edbc2e7b5c37aa7b5d9ec1e66f169b531c3941eae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656d72616e2f6d617277612d766965772e737667)](https://packagist.org/packages/memran/marwa-view)[![CI](https://github.com/memran/marwa-view/actions/workflows/ci.yml/badge.svg)](https://github.com/memran/marwa-view/actions/workflows/ci.yml)[![PHP 8.2+](https://camo.githubusercontent.com/621fdca541f24335b431f1150245e30245c59db9ea5faafd3ba91c224ce4abb8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737376262342e737667)](https://www.php.net/)[![PHPStan 2.x](https://camo.githubusercontent.com/83bee26ca8e5e492b642644349d439a0e9d9844654067dbdc4708987289cb547/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d322e782d3331433635322e737667)](https://phpstan.org/)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

`Marwa\View` is a framework-agnostic view layer for PHP 8.2+ built on Twig. It gives application code a small public API, optional PSR-16 fragment caching, theme inheritance, and extension points without forcing the rest of the app to depend directly on Twig internals.

Documentation is split into focused guides under [docs/README.md](docs/README.md). Start there to browse tutorials, API references, themes, extensions, examples, and development notes.

Features
--------

[](#features)

- Small public API centered on `View`, `ViewConfig`, and `ViewInterface`
- Twig-powered rendering with strict variables and auto-reload in debug mode
- Shared view data through `share()`
- Nested partial rendering through `view()` inside templates
- Namespaced views for modular template directories like `@Blog/post/index`
- Layout stack helpers through `push()`, `prepend()`, and `stack()`
- PSR-16 fragment caching through `fragment()`
- Optional runtime theme switching with `ThemeBuilder`
- Theme inheritance for templates and theme-specific asset URLs
- Optional extensions for assets, URLs, text helpers, dates, translations, HTML attributes, Alpine.js directives, JSON output, and money formatting
- PHPUnit, PHPStan 2.x, PHP-CS-Fixer, Composer scripts, and GitHub Actions CI

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

[](#requirements)

- PHP 8.2+
- Composer 2

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

[](#installation)

```
composer require memran/marwa-view
```

For package development:

```
composer install
```

Documentation
-------------

[](#documentation)

- [Documentation Index](docs/README.md)
- [Tutorials](docs/tutorials.md)
- [API Reference](docs/api.md)
- [Module Views](docs/modules.md)
- [Extensions](docs/extensions.md)
- [Create an Extension](docs/create-extension.md)
- [Themes](docs/themes.md)
- [Create a Theme](docs/create-theme.md)
- [Framework Integration](docs/framework-integration.md)
- [Examples](docs/examples.md)
- [Development](docs/development.md)

Tutorial
--------

[](#tutorial)

### 1. Create a views directory

[](#1-create-a-views-directory)

```
project/
  views/
    home/
      index.twig
  storage/
    views/

```

### 2. Configure the renderer

[](#2-configure-the-renderer)

```
