Thursday, March 8, 2012

Symfony sfConfig Variables

This page was originally available here: Doggetto.com. However the page is unavailable now, thus I publish this copy.

Reference to Config Variables

  • Be careful in referencing any app-specific variables in the model in a multi-app project.  If they are not available in the app you are using the model function in you will have problems.
sfConfig::get('sf_config_variable', 'The default value'); // The default is optional.

Symfony Framework

sf_symfony_lib_dir
The real path to the framework’s lib directory
(/usr/share/php/symfony/symfony12/lib)

Project Structure and Layout

sf_root_dir
The path to the project root
(/var/www/project_name)
sf_apps_dir
The path to the project’s apps folder
(/var/www/project_name/apps)
sf_lib_dir
The path to the project’s lib folder
(/var/www/project_name/lib)
sf_log_dir
The path to the project’s log folder
(/var/www/project_name/log)
sf_data_dir
The path to the project’s data folder
(/var/www/project_name/data)
sf_config_dir
The path to the project’s config folder
(/var/www/project_name/config)
sf_test_dir
The path to the project’s test folder
(/var/www/project_name/test)
sf_doc_dir
The path to the project’s doc folder
(/var/www/project_name/doc)
sf_plugins_dir
The path to the project’s plugins folder
(/var/www/project_name/plugins)
sf_cache_dir
The path to the project’s plugins folder
(/var/www/project_name/cache)
sf_web_dir
The path to the project’s plugins folder
(/var/www/project_name/web)
sf_upload_dir
The path to the project’s upload folder
(/var/www/project_name/web/uploads)

Application Information

sf_app
The current application
(backend)
sf_environment
The current environment
(dev)
sf_debug
Whether debugging is enabled
(1)

Application Structure and Layout

sf_app_dir
The path to the current application
(/var/www/project_name/apps/backend)
sf_app_config_dir
The path to the current application’s config directory
(/var/www/project_name/apps/backend/config)
sf_app_lib_dir
The path to the current application’s lib directory
(/var/www/project_name/apps/backend/lib)
sf_app_module_dir
The path to the current application’s module directory
(/var/www/project_name/apps/backend/modules)
sf_app_template_dir
The path to the current application’s template directory
(/var/www/project_name/apps/backend/templates)
sf_app_i18n_dir
The path to the current application’s i18n directory
(/var/www/project_name/apps/backend/i18n)

Cache Structure and Layout

sf_app_base_cache_dir
The path to the current application’s directory in the cache
(/var/www/project_name/cache/backend)
sf_app_cache_dir
The path to the current application’s directory in the cache by current environment
(/var/www/project_name/cache/backend/dev)
sf_template_cache_dir
The path to the current application’s templates directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/template)
sf_i18n_cache_dir
The path to the current application’s i18n directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/i18n)
sf_config_cache_dir
The path to the current application’s config directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/config)
sf_test_cache_dir
The path to the current application’s test directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/test)
sf_module_cache_dir
The path to the current application’s modules directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/modules)

Application Settings

You can access any value in settings.yml by prepending “sf_” to the value.
sf_error_404_module
The module that contains the 404 action (default)
sf_error_404_action
The action that displays the 404 error (error404)
sf_logging_enabled
Boolean for whether logging is currently enabled (1)
sf_escaping_strategy
Whether the sfView class is using the Escaping Strategy (1)
sf_no_script_name
Whether the application is requiring the script name. (1)
sf_csrf_secret
The CSRF secret (UniqueSecret)

Also:

You can grab some information from the current context (usually in templates, but should work well enough in actions – I’d be very cautious about using these in models):
sfContext::getInstance()->getActionName();
The name of the current action.  Can also be called by $this->getActionName() in templates.
(my_awesome_action)
sfContext::getInstance()->getModuleName();
The name of the current module.  Can also be called by $this->getModuleName() in templates.
(my_awesome_module)
sfContext::getInstance()->getModuleDirectory();
The path to the current module’s directory
(/var/www/project_name/apps/backend/modules/my_awesome_module)

No comments:

Post a Comment