machuga / codeigniter-presenter-spark

Easily implement the Presenter pattern to keep your views clean

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Presenter Spark

Presenter is designed to allow you to implement the presenter pattern easily in your CodeIgniter views.

Installation

Sparks Manager

In your shell, navigate to the root of your CodeIgniter project and run

php tools/spark install presenter

Manually

  • Navigate to your CodeIgniter project's 'sparks' folder
  • Extract the presenter spark here, ensure it is named 'presenter'

Additionally

Be sure to create a directory named 'presenters' in your application folder

How To

You may choose to either autoload the spark, or load it manually via

$this->load->spark('presenter/<version_number>');

To load the presenter, use:

$this->presenter->load('user', $user)

The second parameter is optional, and may be loaded as an individual instance later via:

$user_presenter = new User_Presenter($user);

Conventionally, if you have a 'User' model, you would name the presenter 'User_Presenter', and the file name 'user_presenter.php'. For clarification, it is assumed that the presenter will be named the same as your model, and the file name will be all lowercase.

Examples coming soon!

Contact and Credit

This spark was created and is maintained by Matthew Machuga, is hosted on GitHub, and is made possible by the GetSparks team. Please support their project!

About

Easily implement the Presenter pattern to keep your views clean


Languages

Language:PHP 100.0%