PHPackages                             avik/canvas - 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. avik/canvas

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

avik/canvas
===========

Minimal declarative PHP view layer for the Avik framework

v1.1.1(1mo ago)0183MITPHPPHP &gt;=8.1

Since Dec 28Pushed 1mo agoCompare

[ Source](https://github.com/aviyandev/avik-canvas)[ Packagist](https://packagist.org/packages/avik/canvas)[ RSS](/packages/avik-canvas/feed)WikiDiscussions main Synced 1mo ago

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

avik/canvas
===========

[](#avikcanvas)

Canvas is the view and template layer of the Avik framework.

It is intentionally **simple**, **PHP-first**, and **predictable**.

Canvas is **not Blade**, **not a new language**, and **not a logic engine**. It is a very thin declarative layer that compiles to plain PHP and renders HTML.

---

Philosophy
----------

[](#philosophy)

Canvas follows these strict principles:

- PHP remains PHP
- HTML remains readable
- No magic runtime parsing
- No heavy DSL or expression language
- Compile once, render many times
- Syntax is intentionally limited
- Future power grows internally, not via new syntax

> Canvas is designed to be stable for years without redesign.

---

What Canvas Is
--------------

[](#what-canvas-is)

- A view renderer
- A PHP execution wrapper
- A minimal declarative syntax for common patterns
- A compiled, cached template system

---

What Canvas Is NOT
------------------

[](#what-canvas-is-not)

- Blade
- Twig
- A logic engine
- A controller system
- A reactive system
- A component framework (yet)

Canvas does **not** try to replace PHP. It only removes small pain points.

---

Supported Syntax (Final &amp; Closed)
-------------------------------------

[](#supported-syntax-final--closed)

⚠️ The syntax below is **FINAL and IMMUTABLE**. No new directives will be added in future versions.

### Output

[](#output)

```
{{ variable }}        escaped output
{!! variable !!}      raw output
###Loop
@each items as item
    ...
@endEach

Meaning:

foreach ($items as $item)

###Conditional Display (truthy only)
@show variable
    ...
@endshow

Meaning:

if (!empty($variable))

###There is intentionally:

no else

no elseif

###This keeps templates simple and readable.

### Layouts
@layout app

@content
    ...
@endcontent

app refers to app.avik.php. The layout controls the structure, while child views define the content.

### Components & Slots
Components can now receive data and use slots for flexible content.

```text
@component('card', ['title' => 'User Profile'])
    @slot('body')
        This is the profile body.
    @endslot
@endcomponent

```

In `components/card.avik.php`:

```

    {{ title }}

        @yieldSlot('body')

```

### Advanced Features

[](#advanced-features)

- **View Composers**: Bind data to specific views automatically.
- **Custom Directives**: Extend the compiler with your own syntax.
- **Shared Data**: Share variables across all views.
- **Exception Handling**: Detailed exceptions for missing views or components.

### Example Usage

[](#example-usage)

```
$factory->share('app_name', 'Avik App');

$factory->composer('profile', function($data) {
    $data['user'] = User::current();
    return $data;
});

$factory->directive('datetime', function($expression) {
    return "";
});
```

Rendering a View $factory = new Factory( viewsPath: **DIR** . '/views', cachePath: **DIR** . '/storage/canvas' );

$view = $factory-&gt;make('home', \[ 'title' =&gt; 'Welcome', 'users' =&gt; $users, 'isAdmin' =&gt; true, \]);

echo $view-&gt;render();

Compilation &amp; Caching

Templates are compiled to plain PHP

Compiled files are cached by file hash

No runtime parsing

No performance penalty after first render

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity45

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

Every ~45 days

Total

3

Last Release

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bcc09bf6856ea999081c782fcefa350bcae89f459c4ca4bd628a130d5bcac80?d=identicon)[aviyandev](/maintainers/aviyandev)

---

Top Contributors

[![aviyandev](https://avatars.githubusercontent.com/u/39535998?v=4)](https://github.com/aviyandev "aviyandev (8 commits)")

### Embed Badge

![Health badge](/badges/avik-canvas/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

555.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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