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

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

switon/view
===========

HTML views with request-scoped state, controller template resolution, and an HTTP response bridge for Switon Framework

v1.0.0(1mo ago)021MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 1mo agoCompare

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

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

Switon View Package
===================

[](#switon-view-package)

[![CI](https://camo.githubusercontent.com/fc7e6aee781c13f089a2b7bcb4a7e148d1ecd213b5b03b1be43a262bc4f250ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f766965772f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/view/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's view layer for router-mapped HTML actions, request-local state, widgets, and layout/block rendering.

Highlights
----------

[](#highlights)

- **View routing:** `#[ViewMapping]` and related attributes route page actions into the HTML view flow.
- **Flexible template resolution:** `ViewInterface::render()` accepts direct template paths and `Controller::Action`targets.
- **Shared layout shell:** `setLayout()`, `@section`, and `@yield` let page templates reuse one wrapper.
- **Request-local view state:** `ViewContext` keeps layout, variables, and rendered content together.
- **Widget support:** reusable page parts can be built with widget contracts.
- **HTTP bridge:** `ViewRenderer` turns action return values into rendered HTML responses.

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

[](#installation)

```
composer require switon/view
```

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

[](#quick-start)

```
use Switon\Routing\Attribute\RequestMapping;
use Switon\Routing\Attribute\ViewMapping;
use Switon\Viewing\ViewInterface;
use Switon\Core\Attribute\Autowired;

#[RequestMapping('/user')]
class UserController
{
    #[Autowired] protected ViewInterface $view;

    #[ViewMapping('profile')]
    public function profileAction(): array
    {
        return [
            'title' => 'Profile',
            'user' => ['name' => 'Mark'],
        ];
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (1 commits)")

---

Tags

renderingswitontemplatesviewviewtemplatesRenderingswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7528.4M270](/packages/laminas-laminas-view)[shoot/shoot

Shoot aims to make providing data to your templates more manageable

40229.9k2](/packages/shoot-shoot)[view-components/view-components

Flexible Framework-Agnostic UI for Enterprise Web Applications

24113.3k7](/packages/view-components-view-components)[san-kumar/laravel-crud

Laravel CRUD generator: Generate CRUD for any db table with the crud:generate command.

564.7k](/packages/san-kumar-laravel-crud)

PHPackages © 2026

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