0

I'm creating a Yii widget on a project and I've run into a problem, albeit following all the naming conventions correctly.

Got an error

include(RecentCommentsWidget.php): failed to open stream: No such file or directory

I have included the path application.components.* on main.php correctly but I don't know why it is not detecting.

The recentCommentsWidget.php is saved in a views directory inside the components directory.

Is there anything am missing?

EDIT: Here is the RecentCommentsWidget class ( path => application/components)

class RecentCommentsWidget extends CWidget
{
private $_comments;
public $displayLimit = 5;
public $projectId = null;

public function init()
{
    if(null !== $this->projectId)
        $this->_comments = Comment::model()->with(array(
            'issue'=>array('condition'=>'project_id='.$this->projectId)))->recent($this->displayLimit)->findAll();
    else
        $this->_comments = Comment::model()->recent($this->displayLimit)->findAll();
}

public function getData()
{
    return $this->_comments;
}

public function run()
{
    // this method is called by CController::endWidget()
    $this->render('recentCommentsWidget');
}
}

recentCommentsWidget file (path => application/components/views)

<ul>
    <?php foreach($this->getData() as $comment): ?>
    <div class="author">
        <?php echo $comment->author->username; ?> added a comment.
    </div>
    <div class="issue">
        <?php echo CHtml::link(CHtml::encode($comment->issue->name),array('issue/view', 'id'=>$comment->issue->id)); ?>
    </div>
    <?php endforeach; ?>
</ul>

and this is how i am calling it the views

<?php $this->widget('RecentCommentsWidget'); ?>

SOLVED: I had wrote recentComments.php instead of recentCommentsWidget.php

Richie
  • 1,398
  • 1
  • 19
  • 36
  • 2
    Show your class declaration, show how you are calling this widget. Try also including `application.components.views.*`, rename file to `RecentCommentsWidget.php` (first Uppercase letter). – Justinas Dec 04 '14 at 07:44
  • No need to include `application.components.views.*` - this only import classes.`CWidget` will resolve view path. Only rename as pointed in @Justinas comment. –  Dec 05 '14 at 09:26

0 Answers0