2012-09-22 78 views
1

我是新的Zend Framework 1.11和Propel ORM,我遇到了一個非常簡單的案例。這裏是關於URL http://fle.localhost/domain錯誤:警告:require_once(phing/BuildException.php):未能打開流

Warning: require_once(phing/BuildException.php): failed to open stream: No such file or directory in /var/projects/library/vendor/propel/propel1/generator/lib/exception/EngineException.php on line 11

Fatal error: require_once(): Failed opening required 'phing/BuildException.php' (include_path='/var/projects/fle-portal/application/models/propel:/var/projects/fle-portal/application/../library:/var/projects/library/vendor/zendframework/zendframework1/library:/var/projects/library/vendor/propel/propel1/runtime/lib:/var/projects/library/vendor/propel/propel1/generator/lib:/var/projects/library:.:/usr/share/php:/usr/share/pear') in /var/projects/library/vendor/propel/propel1/generator/lib/exception/EngineException.php on line 11

我的網域控制器的indexAction十分簡單:

public function indexAction() 
{ 
    $this->view->messages = $this->_helper->flashMessenger->getMessages(); 
    $this->view->collDomains = Domain::getAll(); 
} 

這一個是調用的Propel對象類Domain.php:

<?php 

/** 
* Skeleton subclass for representing a row from the 'domain' table. 
* 
* You should add additional methods to this class to meet the application requirements. 
* This class will only be generated as long as it does not already exist in the output 
* directory. 
* @package propel.generator.fleazup 
*/ 
class Domain extends BaseDomain 
{ 
    public static function getAll() 
    { 
     return DomainPeer::doSelect(new Criteria()); 
    } 
} 

另外,在視圖中沒有任何困難:views/script/domain/index.phtml:

<!-- CONDITION: if there are domains --> 
<?php 
if (!empty($this->collDomains)): 
?> 

     <!-- if condition ok, display domains table --> 
      <!-- Page header --> 
      <div class="row"> 
       <div class="span12"> 
        <div class="page-header"> 
         <h1>Domains List</h1> 
        </div> 
       </div> 
      </div> 

      <!-- Flash messages --> 
      <div> 
       <?php if (count($this->messages)) : ?> 

        <div class="alert alert-info"> 
         <a class="close" data-dismiss="alert" href="#">×</a> 
         <ul id="messages"> 
          <?php foreach ($this->messages as $message) : ?> 
           <li><?php echo $this->escape($message); ?></li> 
          <?php endforeach; ?> 
         </ul> 
        </div> 
       <?php endif; ?> 
      </div> 

      <!-- Link to add action --> 
      <div> 
       <p><a href="<?php echo $this->url(array('controller'=>'domain', 'action'=>'add'));?>">Add a new domain</a></p> 
      </div> 

      <!-- domains table --> 
      <table class="table table-striped"> 
       <thead> 
        <tr> 
         <th>Id</th> 
         <th>Label</th> 
         <th>Actions</th> 
        </tr> 
       </thead> 

       <tbody> 
        <?php foreach ($this->collDomains as $domain): ?> 
        <tr> 
         <td><?php echo $this->escape($domain->getId()) ?></td> 
         <td><?php echo $this->escape($domain->getLabel()) ?></td> 
         <td> 
          <a href="<?php echo $this->url(array('controller'=>'domain', 'action'=>'modify', 'id'=>$this->escape($domain->getId())));?>">Modify</a> 
          <a href="<?php echo $this->url(array('controller'=>'domain', 'action'=>'delete', 'id'=>$this->escape($domain->getId())));?>">Delete</a> 
         </td> 
        </tr> 
        <?php endforeach; ?> 
       </tbody> 
      </table> 

     <!-- If condition KO --> 
     <?php else: ?> 
      <!-- Page header --> 
      <div class="row"> 
       <div class="span12"> 
        <div class="page-header"> 
         <h1>Domains List</h1> 
        </div> 
       </div> 
      </div> 

      <!-- Link to add action --> 
      <div> 
       <p><a href="<?php echo $this->url(array('controller'=>'domain', 'action'=>'add'));?>">Add a new domain</a></p> 
      </div> 

      <!-- Message --> 
      <p>No domain to display.</p> 

    <!-- End of condition -->   
    <?php endif; ?> 

我不明白的是我對2個其他對象完全一樣,它工作得很好。我只收到Domain對象的錯誤...

您認爲,錯誤來自哪裏? Phing配置?推進配置?代碼? 任何想法幫助我?

回答

0

require_once(phing/BuildException.php): failed to open stream: No such file or directory

這是你的問題。該文件應該存在,你需要找出爲什麼它不存在。

1

這是您自己的Propel生成的模型類Domain與在the generator/lib/model folder中承載相同名稱的Propel供應商類之間的衝突問題。

實際上,所引發的錯誤是誤導性的,因爲它是由Propel供應商類在其上下文之外執行的。當您的代碼嘗試Domain::getAll()時,Propel供應商類會拋出異常,因爲方法getAll()不存在。但是,這個異常一開始就看不到,因爲phing/BuildException.php不在包含路徑(上下文問題)上:這就是爲什麼會出現初始錯誤。我承認,有點棘手的東西。

您可以在爲生成的對象添加前綴中修復此問題。爲此,請將propel.classPrefix屬性設置爲build.properties文件(read the Propel documentation on Customizing Generated Object Model)並重建對象模型。但要小心,你將不得不相應地修改你的代碼。

+0

當我切換到作曲家自動加載器時,只是遇到了同樣的情況。我的命名衝突是我的搜索索引類「索引」。 –

相關問題