MVCnPHP 4.0.0 Released!
It's been a long while since the last stable release but I'm happy to announce the release of MVCnPHP v4.0.0. This release has been a long time coming as it brings a configure-less controller. Just drop your views and commands into the directories you configured the controller to use and it will monitor them for changes. Upon finding a file that has changed it will pull the MVC metadata out and add it to an internal configuration array that the controller will happily load into memory using APC or write out to a .php file. This basically catches this MVC implementation to what's been available in Ruby on Rails. Installation is easy:
#>pear channel-discover pear.geeklog.net #>pear install geeklog/MVCnPHPClick read-more to get some sample code.
Sample use of the controller:
/**
* Bring in the MVC controller
*/
require 'Geeklog/MVCnPHP/Controller.php';
$options = array('doCompileChecks'=>0,
'baseUrl'=>$dodConf['site_url'],
'viewDir'=>$dodConf['path_views'],
'commandDir'=>$dodConf['path_commands'],
'configFileDirectory'=>$dodConf['path'],
'apcOptions'=>array('apc_index'=>MVCnPHP_CONFIG));
$controller = new Geeklog_MVCnPHP_Controller($options');
$controller->processRequest();
Sample View:
/**
* Get abstract Flexy view
*/
require_once getOption('path_views') . 'BaseViewFlexy.php';
/**
* DOD homepage
*
*/
class APP_HomeView extends APP_BaseViewFlexy {
/**
* MVC method to register action name(s)
*
* @return action names this view will be called on
*
*/
public static function getActions() {
return array('home');
}
/**
* Register this view as the default action to take.
*
* @return boolean
*
*/
public static function getIsDefaultAction()
{
return true;
}
/**
* Registers any forwards
*
* @return array
*
*/
public static function getForwards() {
return array();
}
/**
* Generates the HTML content for the Home screen.
* NOTE: this uses PEAR::HTML_Template_Flexy only as an example.
*/
public function processView() {
$this->setPageTitle(getOption('site_name').' - '.getOption('site_slogan'));
$this->showHeader();
$this->flexyHandle->compile('Home.thtml');
$this->flexyHandle->outputObject($this);
$this->showFooter();
}
}