icanboogie/bind-view

Binds icanboogie/view to ICanBoogie

v0.9.0 2018-03-18 00:44 UTC

This package is auto-updated.

Last update: 2024-12-08 02:20:25 UTC


README

Release Build Status Code Quality Code Coverage Packagist

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

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 returned by get_renderer().

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.

Requirements

The package requires PHP 5.6 or later.

Installation

The recommended way to install this package is through Composer:

$ composer require icanboogie/bind-view

Cloning the repository

The package is available on GitHub, its repository can be cloned with the following command line:

$ git clone https://github.com/ICanBoogie/bind-view.git

Documentation

The package is documented as part of the ICanBoogie framework documentation. You can generate the documentation for the package and its dependencies with the make doc command. The documentation is generated in the build/docs directory. ApiGen is required. The directory can later be cleaned with the make clean command.

Testing

The test suite is ran with the make test command. PHPUnit and Composer need to be globally available to run the suite. The command installs dependencies as required. The make test-coverage command runs test suite and also creates an HTML coverage report in "build/coverage". The directory can later be cleaned with the make clean command.

The package is continuously tested by Travis CI.

Build Status Code Coverage

License

icanboogie/bind-view is licensed under the New BSD License - See the LICENSE file for details.