2015-10-15 64 views
0

我試圖運行一個Symfony任務,但是當我嘗試實例化一個類時,我得到一個致命錯誤。Symfony 1.4任務無法訪問類

類位於

  • 應用
    • MyApp的
      • LIB

我的代碼如下

protected function execute($arguments = array(), $options = array()) 
    { 
    $this->reloadAutoload(); 

    // initialize the database connection 
    $databaseManager = new sfDatabaseManager($this->configuration); 
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); 

    // Get file from dir 
    if(!in_array($arguments['filename'] . $this->fileExt, scandir($this->path))) { 
     $this->logSection('Import CSV', 'File doesn\'t exist.', null, 'ERROR'); 
     return; 
    } 

    $path = $this->path . '/' . $arguments['filename'] . $this->fileExt; 

    if(class_exists('CsvReader')) { 
     $csvReader = new CsvReader($path); 
    } else { 
     $this->logSection('Import CSV', 'Class doesn\'t exist.', null, 'ERROR'); 
     return; 
    } 

    // add your code here 
    $this->logSection('Import CSV', 'All content imported.'); 
    } 

如果有什麼我失蹤然後讓我知道,我會修改我的問題。

謝謝。

回答

0

有可能會阻止您在您的應用程序調用類有兩件事情:

  1. 需要刷新緩存與php symfony cc
  2. 你的Symfony自動加載機無法找到你的班級,因爲文件名不.class.php

來源結束:Documentation

+0

凱文您好,感謝您的回覆。我完成了這兩個,它仍然無法實例化。我剛剛採用舊的skool方式,只是使用require_once完成工作。 –