Search by

Provides view support to ICanBoogie

Package info

github.com/ICanBoogie/View

Homepage

pkg:composer/icanboogie/view

Statistics

Installs: 1 118

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v6.0.0 2024-11-19 04:50 UTC

This package is auto-updated.

Last update: 2026-10-13 12:24:51 UTC


README

Release Code Coverage Downloads

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.

Tests Static Analysis Code Style

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.