1
votes

I'm new using Zend Framework 1.11 and Propel ORM together, and I get stuck on a very simple case. Here is the error on the url http://fle.localhost/domain :

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

My DomainController IndexAction is very simple :

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

This one is calling a Propel object class in 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());
    }
}

Also, nothing difficult in the view : 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; ?>

What I do not understand is that I did exactly the same with 2 other Objects and it works very well. I get the error only for the Domain object...

What do you think, where the error comes from ? Phing config ? Propel config ? Code ? Any idea to help me ?

2

2 Answers

1
votes

This is a problem of conflict between your own Propel-generated model class Domain and the Propel vendor class which bears the same name in the generator/lib/model folder.

In fact, the error raised is misleading because it is triggered by the Propel vendor class being executed out of its context. When your code tries Domain::getAll(), the Propel vendor class throws an exception since the method getAll() does not exists. BUT, that exception can't be seen at first because phing/BuildException.php is not on the include path (context issue) : that's why occurs the initial error. Kind of tricky stuff, I confess.

You can fix this in prefixing your generated objects. To do so, set the propel.classPrefix property into your build.properties file (read the Propel documentation on Customizing Generated Object Model) and rebuild your object model. Beware though, you will have to modify your code accordingly.

0
votes

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

This is your issue. The file should exist, and you need to find out why it does not exist.