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(1mo ago)0791MITPHPPHP ^8.2

Since Apr 2Pushed 6mo 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 1mo ago

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

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

[](#marwaview)

A **modern, developer-friendly View Engine** built on top of [Twig](https://twig.symfony.com), designed for **best DX**, **clean integration**, and **PSR-16 fragment caching** — without ever exposing Twig internals.

> ⚙️ Part of the [MarwaPHP](https://github.com/memran) ecosystem.

---

🚀 Features
----------

[](#-features)

- ✅ Thin wrapper — hides Twig from your app code
- ⚡ PSR-16 fragment caching (`fragment('key', ttl, producer)`)
- 🧠 Familiar DX (`View::render()`, `View::share()`, `view()` in templates)
- 🔒 PSR-12, SOLID, framework-agnostic
- 💾 Automatic cache directory management
- 🧩 Extensible via custom Twig Extensions
- 🧰 Debug-safe with strict variables in dev mode

---

📦 Installation
--------------

[](#-installation)

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

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

[](#quick-start)

```
use Marwa\View\View;
use Marwa\View\ViewConfig;
use Symfony\Component\Cache\Simple\Psr16Cache; // or any PSR-16 cache

$config = new ViewConfig(
    viewsPath: __DIR__ . '/views',
    cachePath: __DIR__ . '/storage/views',
    debug: true,
    fragmentCache: new Psr16Cache() // optional
);

$view = new View($config);
$view->share('appName', 'EnetFlow');

// Render a view
echo $view->render('home/index', ['title' => 'Welcome']);
```

Example Template
----------------

[](#example-template)

```
{# views/home/index.twig #}

  {{ title }} - {{ appName }}

    Hello {{ title }}
    {{ view('components/footer')|raw }}

    {# Cache fragment for 5 min (300s) #}
    {{ fragment('sidebar', 300, {
      template: 'partials/sidebar',
      data: { name: 'Emran' }
    })|raw }}

```

Integrating with a Container
----------------------------

[](#integrating-with-a-container)

```
$container->add(Marwa\View\ViewInterface::class, function() {
    $cfg = new ViewConfig(
        viewsPath: base_path('resources/views'),
        cachePath: storage_path('views'),
        debug: env('APP_DEBUG', false)
    );
    return new View($cfg);
});
```

Testing
-------

[](#testing)

```
composer test
```

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

[](#requirements)

- PHP 8.1 +
- twig/twig ^3.21
- psr/simple-cache ^3.0

License
-------

[](#license)

MIT © Mohammad Emran

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance79

Regular maintenance activity

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cf906a31a250a940314fe42f8a18f449647bfe18095457350ff0081cf8dd3c2?d=identicon)[memran](/maintainers/memran)

---

Top Contributors

[![memran](https://avatars.githubusercontent.com/u/7415198?v=4)](https://github.com/memran "memran (22 commits)")

---

Tags

twigcachepsr-16templatephp8DXView EngineMarwa

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[wyrihaximus/twig-view

Twig powered View for CakePHP

804.7M1](/packages/wyrihaximus-twig-view)[twig/cache-extra

A Twig extension for Symfony Cache

392.1M20](/packages/twig-cache-extra)[oro/twig-inspector

Oro Twig Inspector adds the possibility to find twig templates and blocks used for rendering HTML pages faster during development

47532.6k14](/packages/oro-twig-inspector)[shapecode/twig-template-event-bundle

Possibility to add code in a twig template dynamically

1010.7k](/packages/shapecode-twig-template-event-bundle)

PHPackages © 2026

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