Search by

icanboogie / bind-view

olvlvl

Binds icanboogie/view to ICanBoogie

Package info

github.com/ICanBoogie/bind-view

Homepage

pkg:composer/icanboogie/bind-view

Statistics

Installs: 713

Dependents: 3

Suggesters: 1

Stars: 0

Open Issues: 0

v6.0.0 2023-02-07 22:15 UTC

This package is auto-updated.

Last update: 2026-10-14 11:33:57 UTC


README

Release Downloads

The icanboogie/bind-view package binds icanboogie/view to ICanBoogie, using its autoconfig feature. It adds getters to controllers and views, making it easy to invoke views from controller actions or get template engines and resolve templates from views, using features of icanboogie/render.

Installation

composer require icanboogie/bind-view

Views and controllers

Views are associated with controllers through the lazy getter view, thus a simple $this->view is all that is required to enable view features inside a controller. The view then waits for the Controller::action event to perform its rendering.

The View instance is created with the controller and the Renderer instance obtained from the container.

The following example demonstrates how a query of some articles is set as the view content, a title is also added to the view variables:

<?php

use ICanBoogie\Routing\Controller;

class ArticlesController extends Controller
{
    use Controller\ResourceTrait;

    protected function index()
    {
        $this->view->content = $this->model->own->visible->ordered->limit(10);
        $this->view['title'] = "Ten last articles";
    }
}

Note: The model getter is provided by the icanboogie/module package, and is only available if the route has a module property, which is automatic for routes defined by modules.

For more information continue to the View documentation.

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.