【问题标题】:Warning: require_once(phing/BuildException.php): failed to open stream警告:require_once(phing/BuildException.php):无法打开流
【发布时间】:2012-09-22 06:57:56
【问题描述】:

我是一起使用 Zend Framework 1.11 和 Propel ORM 的新手,我遇到了一个非常简单的案例。这是 url http://fle.localhost/domain 上的错误:

警告:require_once(phing/BuildException.php):打开失败 流:中没有这样的文件或目录 /var/projects/library/vendor/propel/propel1/generator/lib/exception/EngineException.php 在第 11 行

致命错误:require_once():需要打开失败 '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/梨') 在 /var/projects/library/vendor/propel/propel1/generator/lib/exception/EngineException.php 在第 11 行

My DomainController IndexAction 非常简单:

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

这是在 Domain.php 中调用 Propel 对象类:

<?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 个对象做了完全相同的事情,而且效果很好。我只收到域对象的错误...

你怎么看,错误来自哪里?平配置?推进配置?代码 ? 有什么想法可以帮助我吗?

【问题讨论】:

    标签: php zend-framework propel phing


    【解决方案1】:

    这是您自己的 Propel 生成的模型类 Domainthe 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) 中并重建您的对象模型。但请注意,您必须相应地修改您的代码。

    【讨论】:

    • 当我切换到作曲家自动加载器时遇到了同样的事情。我的命名冲突是我的搜索索引类Index
    【解决方案2】:

    require_once(phing/BuildException.php):打开流失败:没有这样的文件或目录

    这是你的问题。该文件应该存在,您需要找出它不存在的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-14
      • 2014-11-18
      • 2019-12-08
      • 1970-01-01
      • 1970-01-01
      • 2011-10-17
      • 2012-01-27
      • 1970-01-01
      相关资源
      最近更新 更多