tags:

views:

746

answers:

3

I have a few of my own constants in symfony, and I need to make them available throughout the application, where to best define them?

I tried, in the directory myapps\config\config.php, define my constant in this way:

sfConfig::set('aaa', 'mya');

But when I tried to access the constant in myapps\apps\frontend\modules\login\actions\actions.class.php, using this comand

sfConfig::get('aaa')

I simply get a null, indicating that it hasn't been defined.

How and where to define symfony constant so that it is accessible throughout the whole project?

+1  A: 

looks like you are trying to use symfony 1.0 style configuration with symfony 1.1 or 1.2. all config.php files have been removed in 1.1. see Overview of the Configuration Files for what to use instead. and always be sure to look at the documentation for the proper version (*1_2* (or whatever version you are using) in the url).

ax
A: 

This is how I solved the problem:

Put the following into my myapp/apps/frontend/config/app.yml:

all:
  .app_set:
    bpobackend:       me
    bpoRedirectScreen:    allow

Then in action module, call the var_dump to check the value

var_dump(sfConfig::get('app_bpobackend'));
Ngu Soon Hui
A: 

Hiii I have tried to add constant in the config.php in Symfony 1.0..

So If you want to add constant variables in config.php then

sfConfig::add(array('SF_DEFAULT_DATEFORMAT' => 'dd-MM-yyyy'));

This is the code where I have define the date format with name 'SF_DEFAULT_DATEFORMAT'...

So You can Tried with this One ...

--Taral Oza