acHostDependantPlugin - 0.0.7


You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source

acHostDependant plugin

The acHostDependantPlugin is a symfony plugin that provide the ability to have different configuration depending on the hostname.


  • Install the plugin (via a package)

    symfony plugin:install acHostDependantPlugin
  • Install the plugin (via a Subversion checkout)

    svn co plugins/acHostDependantPlugin
  • Activate the plugin in the config/ProjectConfiguration.class.php

    class ProjectConfiguration extends sfProjectConfiguration
      public function setup()

How to use

  • Create a new hostname configuration dir with task acHostDependant::createUser

    $ php symfony acHostDependant::createUser

    Configuration file is created in %sf_root_dir%/users/

  • Edit the %sf_root_dir%/users/

    Edit the db settings and other settings
  • Edit file config/databases.yml edit the "class" and "dsn" line:

        class: acHostDependantDoctrineDatabase
          dsn: 'mysql:host=localhost;dbname='
  • Change the parent class in myUser.class.php

    class myUser extends acHostDependantGuardSecurityUser
  • Now you can use this sf settings:

    sfConfig::get('sf_ac_host') # the hostname
    sfConfig::get('sf_ac_host_dir') # the hostname root folder (es. %sf_root_dir%/users/
    sfConfig::get('sf_ac_host_config_dir') # the hostname config folder (es. %sf_root_dir%/users/
    sfConfig::get('sf_ac_host_uploads_dir') # the hostname uploads folder (es. %sf_root_dir%/users/
    sfConfig::get('sf_ac_host_i18n_dir') # the hostname i18n folder (es. %sf_root_dir%/users/

Customize i18n for every host

If you need customize i18n for one or more host, you can add this small piece of code in your ProjectConfiguration.class.php or in your ApplicationConfiguration.class.php (ex. frontendConfiguration.class.php)

 public function getI18NDirs($moduleName)
   $dirs = parent::getI18NDirs($moduleName);
     array_unshift($dirs, sfConfig::get('sf_ac_host_i18n_dir'));

   return $dirs;

Next create i18n folder in your domain config folder: %sf_root_dir%/users/ and add

Task Command Line

  • In the symfony task command line add the --ac_host parameter:

    Examples: php symfony doctrine:insert-sql --ac_host=""