Skip to content

Instantly share code, notes, and snippets.

@aur1mas
Created November 23, 2010 14:18
Show Gist options
  • Save aur1mas/711823 to your computer and use it in GitHub Desktop.
Save aur1mas/711823 to your computer and use it in GitHub Desktop.
enable zfdebug through resource registration
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.time_zone = "Europe/Vilnius"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.view[] =
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"
autoloaderNamespaces[] = "Core"
autoloaderNamespaces[] = "Doctrine"
doctrine.dsn = "mysql://username:password@host/db_name"
doctrine.models_path = APPLICATION_PATH "/models"
doctrine.data_fixtures_path = APPLICATION_PATH "/configs/data/fixtures"
doctrine.sql_path = APPLICATION_PATH "/configs/data/sql"
doctrine.migrations_path = APPLICATION_PATH "/configs/migrations"
doctrine.yaml_schema_path = APPLICATION_PATH "/configs/schema.yml"
doctrine.model_autoloading = 2
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
doctrine.model_autoloading = 1
[development : production]
resources.Core_Application_Resource_ZFDebug.enabled = true
resources.Core_Application_Resource_ZFDebug.params.plugins[] = "Variables"
resources.Core_Application_Resource_ZFDebug.params.plugins.File.base_path = APPLICATION_PATH "/../"
resources.Core_Application_Resource_ZFDebug.params.plugins[] = "Memory"
resources.Core_Application_Resource_ZFDebug.params.plugins[] = "Time"
resources.Core_Application_Resource_ZFDebug.params.plugins[] = "Registry"
resources.Core_Application_Resource_ZFDebug.params.plugins[] = "Exception"
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
doctrine.model_autoloading = 1
<?php
/**
* This class provides a resource that setup the ZFDebug plugin
*
* @see http://code.google.com/p/zfdebug/
*
*/
class Core_Application_Resource_ZFDebug extends Zend_Application_Resource_ResourceAbstract {
/**
* @var boolean
*/
protected $_init = false;
/**
* @var boolean
*/
protected $_enabled = false;
/**
* @var array
*/
protected $_params = array ();
/**
* Set plugin options
*
* @param array $params
*/
public function setParams(array $params) {
$this->_params = $params;
}
/**
* Return plugin options
*
* @return array
*/
public function getParams() {
return $this->_params;
}
/**
* Activate plugin
*
* @param boolean $enabled
*/
public function setEnabled($enabled) {
$this->_enabled = (boolean) $enabled;
}
/**
* Return true iff plugin should be enabled
*
* @return boolean
*/
public function getEnabled() {
return $this->_enabled;
}
/**
* Defined by Zend_Application_Resource_Resource
*/
public function init() {
$this->initDebugPlugin();
}
/**
* Initialize ZFDebug plugin
*/
public function initDebugPlugin() {
if (!$this->_init && $this->getEnabled()) {
// execute once
$this->_init = true;
// plugin options
$options = $this->getParams();
// bootstrap database
if (isset($options['plugins']['Database'])) {
if ($this->getBootstrap()->hasPluginResource('db')) {
$this->getBootstrap()->bootstrap('db');
}
}
// normalize base_path with realpath
if (isset($options['plugins']['File']['base_path'])) {
$options['plugins']['File']['base_path'] = realpath(
$options['plugins']['File']['base_path']);
}
// register namespace
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
// ensure frontcontroller is initializated
$this->getBootstrap()->bootstrap('frontController');
// instantiate plugin
$debug = new ZFDebug_Controller_Plugin_Debug(
$options);
// add plugin to front controller
$frontController = $this->getBootstrap()->getResource(
'frontController');
$frontController->registerPlugin($debug);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment