Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'creocoder\nestedsets\NestedSetsBehavior' not found #98

Open
yougeen opened this issue May 20, 2016 · 5 comments
Open

Class 'creocoder\nestedsets\NestedSetsBehavior' not found #98

yougeen opened this issue May 20, 2016 · 5 comments

Comments

@yougeen
Copy link

yougeen commented May 20, 2016

Hi,

I followed the read me and used composer for the installation and I cannot install this extension properly.

When I call

$countries = new Menu(['name' => 'Countries']);
$countries->makeRoot();

I receive Class 'creocoder\nestedsets\NestedSetsBehavior' not found

Can someone help me please? Thanks!

@yujin1st
Copy link

look if you set class in namespace section

@yougeen
Copy link
Author

yougeen commented May 20, 2016

In which file do I need to set this? I used the snippets from the readme and created a Menu and MenuQuery Class and in both files I use creocoder\nestedsets\NestedSetsBehavior;

@yujin1st
Copy link

Where do you receive this error? What is shown in log?

@yougeen
Copy link
Author

yougeen commented May 23, 2016

I created a sample Controller and call the model from this one.

The Log shows:

[error][yii\base\ErrorException:1] exception 'yii\base\ErrorException' with message 'Class 'creocoder\nestedsets\NestedSetsBehavior' not found' in /var/www/html/Yii2Dev/basic/models/Menu.php:22

Line 22 is 'class' => NestedSetsBehavior::className(),

   public function behaviors() {
        return [
            'tree' => [
                'class' => NestedSetsBehavior::className(),
                // 'treeAttribute' => 'tree',
                // 'leftAttribute' => 'lft',
                // 'rightAttribute' => 'rgt',
                // 'depthAttribute' => 'depth',
            ],
        ];
    }

the namespace I use in this model is:

namespace app\models;
use Yii;
use creocoder\nestedsets\NestedSetsBehavior;

And in my Controller likes like this:

namespace app\controllers;
use app\models\Menu;
use creocoder\nestedsets\NestedSetsQueryBehavior;

class MenuController extends \yii\web\Controller
{
    public function actionIndex()
    {
        $countries = new Menu(['name' => 'Countries']);
        $countries->makeRoot();

        return $this->render('index');
    }

}

Hope this helps you

@kwazaro
Copy link

kwazaro commented Jul 8, 2016

Check the vendor folder for extension files, maybe this extension was installed incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants