This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » Best procedure for including files based on configuration settings
icon5.gif  Best procedure for including files based on configuration settings [message #103370] Sun, 01 August 2010 10:19
daringdirk
Messages: 1
Registered: August 2010
Junior Member
Hi,

I am a complete Symfony beginner and I'm getting nowhere fast, so I need help Smile

Much like in the Jobeet tutorial, I'm using config/ProjectConfiguration.class.php to initialize my application with some libraries I'd written in a previous project, so it looks something like:

  static protected $libsLoaded = false;

  static public function registerLibs()
  {
    // Determine if the libraries have been loaded
    if (!self::$libsLoaded)
    {
      set_include_path(sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path());
      require_once (sfConfig::get('sf_lib_dir').'/vendor/mylibs/libs.php');
      self::$libsLoaded = true;
    }
  }

  public function setup()
  {
    // Enable the Doctrine plugin
    $this->enablePlugins('sfDoctrinePlugin');

    // Enable the required libraries
    $this->registerLibs();
  }


The problem is that I need to include a specific file, depending on a configuration setting.
For example, let's assume I need to include an accounting library based on a country, I was hoping I could define the country setting somewhere and then use sfConfig to include the required file.
I really wanted to place my setting into settings.yml, but that didn't work. So I tried app.yml. Also didn't work. As far as I can see, certain setting files aren't loaded at this point (ie. within ProjectConfiguration.class.php).

So my question is, if I wanted to do something like:

#CONFIG FILE#
all:
  filetoload: canada


require_once (sfConfig::get('sf_lib_dir').'/vendor/mylibs/'.sfConfig::get('app_filetoload').'_libs.php');


What is the best (ie. most correct in Symfony world) way to go about it? Which files would everyone recommend editing?
I would like this to be on an application wide basis rather than per module.

Thanks!
Previous Topic:symfony 1.4 and ssl
Next Topic:┬┐The best way to add new locale properties with i18n? (sfCultureInfo)
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software