dimanche 17 octobre 2010

Finding the path of a config directory in symfony

I had to directly work with a config file in xml, finding the path need the use of constants thus in first place I build the paths with constatnts :

http://www.symfony-project.org/reference/1_4/en/03-Configuration-Files-Principles

$this->path = SF_ROOT_DIR . DIRECTORY_SEPARATOR .
"apps" . DIRECTORY_SEPARATOR .
"reporting" . DIRECTORY_SEPARATOR .
"config" . DIRECTORY_SEPARATOR
. "monitor.xml";

But I got this warning Notice:

Use of undefined constant SF_ROOT_DIR - assumed 'SF_ROOT_DIR'

You cannot directly use the constant you must use sfConfig::get

$this->path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR .
"apps" . DIRECTORY_SEPARATOR .
"reporting" . DIRECTORY_SEPARATOR .
"config" . DIRECTORY_SEPARATOR
. "monitor.xml";

Aucun commentaire: