user1085195
user1085195

Reputation: 395

symfony 1.4, accessing module level lib in a custom task

I have 2 applications: frontend and backend.

I am running the custom task with the following command:

php symfony newCron:createClusters --application=frontend

In each applications I have a lib folder and a modules folder. Through the above command only this apps->frontend->lib folder is accessible, whereas the lib folder in apps->frontend->modules->module1->lib is not accessible.

How can I access the module level lib files in my task?

I tried using the addOption command in the config method, but still nothing happens.

Upvotes: 0

Views: 1636

Answers (1)

j0k
j0k

Reputation: 22756

I think you have two options.

The "symfony way"

Using autoload.yml (in apps/frontend/config/autoload.yml):

autoload:
  my_module_lib:
    path:        %SF_APP_MODULE_DIR%/name_of_your_module/lib
    recursive:   true

The "php old way"

Using basic require_once inside your task:

class createClustersTask extends sfBaseTask
{
  /**
   * @see sfTask
   */
  protected function configure()
  {
    require_once sfConfig::get('sf_app_module_dir') . '/name_of_your_module/lib/name_of_your_first_lib.class.php';
    require_once sfConfig::get('sf_app_module_dir') . '/name_of_your_module/lib/name_of_your_second_lib.class.php';

Upvotes: 1

Related Questions