Friday, October 8, 2010

Get certain system path in a Symfony project

Sometimes you need to include a php file from certain system path in Symfony within a action.class.php.
The code to do that looks like be:
include_once sfConfig::get("sf_app_dir")."/lib/Helper.php";
Symfony has different keys that resolve to a certain directory in the project. The base directory in the below example is example_app in the Apache2 default folder /var/www.


sfConfig::get("sf_root_dir");          # /var/www/example_app
sfConfig::get("sf_apps_dir");          # /var/www/example_app/apps
sfConfig::get("sf_app_dir");           # /var/www/example_app/apps/frontend 
sfConfig::get("sf_app_config_dir");    # /var/www/example_app/apps/config
sfConfig::get("sf_app_i18n_dir");      # /var/www/example_app/apps/i18n
sfConfig::get("sf_app_lib_dir");       # /var/www/example_app/apps/lib
sfConfig::get("sf_app_module_dir");    # /var/www/example_app/apps/modules
sfConfig::get("sf_app_template_dir");  # /var/www/example_app/apps/templates
sfConfig::get("sf_cache_dir");         # /var/www/example_app/cache
sfConfig::get("sf_app_base_cache_dir");# /var/www/example_app/cache/frontend
sfConfig::get("sf_app_cache_dir");     # /var/www/example_app/cache/frontend/dev
sfConfig::get("sf_template_cache_dir");# /var/www/example_app/cache/frontend/dev/templates
sfConfig::get("sf_i18n_cache_dir");    # /var/www/example_app/cache/frontend/dev/i18n
sfConfig::get("sf_config_cache_dir");  # /var/www/example_app/cache/frontend/dev/config
sfConfig::get("sf_test_cache_dir");    # /var/www/example_app/cache/frontend/dev/test
sfConfig::get("sf_module_cache_dir");  # /var/www/example_app/cache/frontend/dev/modules
sfConfig::get("sf_config_dir");        # /var/www/example_app/config
sfConfig::get("sf_data_dir");          # /var/www/example_app/data
sfConfig::get("sf_doc_dir");           # /var/www/example_app/doc
sfConfig::get("sf_lib_dir");           # /var/www/example_app/lib
sfConfig::get("sf_log_dir");           # /var/www/example_app/log
sfConfig::get("sf_test_dir");          # /var/www/example_app/test
sfConfig::get("sf_plugins_dir");       # /var/www/example_app/plugins
sfConfig::get("sf_web_dir");           # /var/www/example_app/web
sfConfig::get("sf_upload_dir");        # /var/www/example_app/uploads

0 comments:

Post a Comment