icanboogie / view
Provides view support to ICanBoogie
Requires
- php: >=8.2
- ext-json: *
- icanboogie/event: ^6.0
- icanboogie/render: ^6.0
- icanboogie/routing: ^6.0
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.4
Suggests
- icanboogie/bind-view: Binds the package to ICanBoogie
Provides
None
Conflicts
None
Replaces
None
README
The icanboogie/view package provides the view part of the model-view-controller (MVC) architectural pattern. It extends the features of the icanboogie/routing package—more precisely its controllers—and together with the icanboogie/render package it helps in separating presentation from logic.
Installation
composer require icanboogie/view
Usage
Actions of stateless controllers return a view, the template and layout are resolved from the route when the view is turned into a response.
<?php namespace App\Articles; use ICanBoogie\Routing\Attribute\Get; use ICanBoogie\View\ViewTrait; use ICanBoogie\View\View; use ICanBoogie\View\ViewProvider; final class ArticleController { use ViewTrait; public function __construct( private readonly ViewProvider $view_provider, private readonly ArticleRepository $articles, ) { } #[Get('/articles')] public function list(): View { return $this->view( content: $this->articles->latest(10), locals: [ 'title' => "Last ten articles" ], ); } }
Read the documentation to learn how to provide views, how templates and layouts are resolved, and how to alter views with events.
Continuous Integration
The project is continuously tested by GitHub Actions.
Code of Conduct
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.
Contributing
See CONTRIBUTING for details.