我已按照How to manage your own cross-apps/global configuration values中的建议在文件config/project.yml
中设置了一些自定义symfony项目级设置。按照这些说明我添加了行
require_once sfConfigCache::getInstance()->checkConfig('config/project.yml');
到我的configure
应用程序的client
文件的clientConfiguration.class.php
方法。
然后我使用php symfony generate:task
创建了一个新的symfony任务。在这个新任务中,我想访问config/project.yml
文件中的设置。这是任务的执行部分:
protected function execute($arguments = array(), $options = array()){
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$configuration = ProjectConfiguration::getApplicationConfiguration('client', 'test', true);
echo sfConfig::get('project_mail_webmaster') . "\n" ;
}
但是,当我运行任务时,我收到此错误:
PHP Fatal error: Call to undefined method sfConfigCache::getInstance() in /opt/sfproject/apps/client/config/clientConfiguration.class.php on line 7
http://trac.symfony-project.org/wiki/HowToHandleCrossAppsConfigurationFiles