/** * Do some sanity checking and framework setup */ public function setup() { global $maintClass; // Abort if called from a web server if (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) { $this->error('This script must be run from the command line', true); } if (version_compare(phpversion(), '5.2.4') >= 0) { // Send PHP warnings and errors to stderr instead of stdout. // This aids in diagnosing problems, while keeping messages // out of redirected output. if (ini_get('display_errors')) { ini_set('display_errors', 'stderr'); } // Don't touch the setting on earlier versions of PHP, // as setting it would disable output if you'd wanted it. // Note that exceptions are also sent to stderr when // command-line mode is on, regardless of PHP version. } // Set max execution time to 0 (no limit). PHP.net says that // "When running PHP from the command line the default setting is 0." // But sometimes this doesn't seem to be the case. ini_set('max_execution_time', 0); $this->loadParamsAndArgs(); $this->helpIfRequested(); $this->adjustMemoryLimit(); // --- Initialize core services --- $configNode = $this->getOption('config-node'); $configFile = $this->getOption('config-file'); $config = Configuration::createForViewWithOverrideFile($configNode, $configFile); Context::init($config); Logger::init($config->val('logging/root-context') . '-' . end(explode("\\", $maintClass)), $config->val('logging/log-level'), $config, Context::get()->getContextId()); Logger::getContext()->addLogStream(new ConsoleLogStream()); set_error_handler('\\SmashPig\\Maintenance\\MaintenanceBase::lastChanceErrorHandler'); set_exception_handler('\\SmashPig\\Maintenance\\MaintenanceBase::lastChanceExceptionHandler'); }
/** * Set a test configuration and initialize the context * * @param string $configNode node to use for configuration overrides * @param string $configPath path to configuration override file * @return Configuration */ function setConfig($configNode = 'default', $configPath = null) { $config = Configuration::createForViewWithOverrideFile($configNode, $configPath); Context::initWithLogger($config); return $config; }
public static function instance() { return Configuration::createForViewWithOverrideFile('default', __DIR__ . '/data/config_smashpig_db.yaml'); }