2016-07-08 42 views
2

我有一個名爲FilterInput的PHP類。當我的基於Symfony(3.0.3)的應用程序調用FilterInput的靜態成員函數時,將隱式調用Symfony的DebugClassLoader。該方法被稱爲loadClass並開始像這樣:symfony 3應用程序無法默默地在DebugClassLoader中require_once

public function loadClass($class) 
{ 
    ErrorHandler::stackErrors(); 

    try { 
     if ($this->isFinder) { 
      if ($file = $this->classLoader[0]->findFile($class)) { 
       require_once $file; 
      } 
     } else { 
      call_user_func($this->classLoader, $class); 
      $file = false; 
     } 
    } finally { 
     ErrorHandler::unstackErrors(); 
    } 
... 

我觀察的問題是,當執行到達include_once指令,應用程序就會失敗。也就是說,http請求返回空,並且在dev.log或我的apache日誌中沒有輸出。我已驗證$file變量包含完整且正確的/path/to/FilterInput.php。我也驗證過這個文件是可讀的。所以我的問題是:

  1. 爲什麼執行停止在這一點?
  2. 它爲什麼會在沒有日誌錯誤消息或響應中返回數據的情況下失敗。

編輯:進一步的信息:如果我填寫垃圾路徑,例如, 「/ foo/bar」然後我得到一個錯誤信息Compile Error: AppBundle\Components\Factory::getDBO(): Failed opening required '/foo/bar' (include_path='.:');所以大概無聲的失敗與某個事實有關,在給定路徑的文件。

+1

您確定處於開發模式?在你的app.php中,確保你像下面這樣實例化你的AppKernel:'$ kernel = new AppKernel('dev',true);' –

+0

幫助我找到了很多先前忽略的錯誤 - 但我仍然**無聲**在require_once上失敗 – Black

回答

3

require_once將失敗默默地病程的如果一條指令,例如:

defined('PATH_BASE') or die(); 

出現在源文件的頭部;並且所需的定義不存在

相關問題