Download the PHP package avik/canvas without Composer
On this page you can find all versions of the php package avik/canvas. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package canvas
Short Description Minimal declarative PHP view layer for the Avik framework
License MIT
Informations about the package canvas
avik/canvas
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
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
- A view renderer
- A PHP execution wrapper
- A minimal declarative syntax for common patterns
- A compiled, cached template system
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 & Closed)
⚠️ The syntax below is FINAL and IMMUTABLE. No new directives will be added in future versions.
Output
text @component('card', ['title' => 'User Profile']) @slot('body')
This is the profile body.
@endslot
@endcomponent html
{{ title }}
### 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
Rendering a View
$factory = new Factory(
viewsPath: __DIR__ . '/views',
cachePath: __DIR__ . '/storage/canvas'
);
$view = $factory->make('home', [
'title' => 'Welcome',
'users' => $users,
'isAdmin' => true,
]);
echo $view->render();
Compilation & Caching
Templates are compiled to plain PHP
Compiled files are cached by file hash
No runtime parsing
No performance penalty after first render