bind-view
, (*1)
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., (*2)
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., (*3)
The View instance is created with the controller and the Renderer instance returned by [get_renderer()
][]., (*4)
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:, (*5)
<?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., (*6)
For more information continue to the View documentation., (*7)
Requirements
The package requires PHP 5.6 or later., (*8)
Installation
The recommended way to install this package is through Composer:, (*9)
$ composer require icanboogie/bind-view
Cloning the repository
The package is available on GitHub, its repository can be
cloned with the following command line:, (*10)
$ 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., (*11)
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., (*12)
The package is continuously tested by Travis CI., (*13)
, (*14)
License
icanboogie/bind-view is licensed under the New BSD License - See the LICENSE file for details., (*15)