Namespace For Kendo Ui Php Wrapper Class?

I have added KendoUI for PHP in my @vendors and created the necessary asset bundle in Yii2. I can create a Kendo javascript widget, such as a datepicker with no problem by registering my script. However, when trying to use the KendoUI for PHP wrapper, I get a Class Not Found Error and am not sure how/where to creat this Class reference or Namespace properly in yii2. What is the proper procedure?

Here is a sample code throwing the error:




$topmenu = new \Kendo\UI\Menu('topmenu');  //error thrown right away due to class \Kendo\UI\Menu not being found               

$help = new \Kendo\UI\MenuItem('Help');

$help->addItem(

     new \Kendo\UI\MenuItem('Customer Support'),				

     new \Kendo\UI\MenuItem('Contact Us')

);

$topmenu->addItem($help);

echo $topmenu->render();



Error message as follows:

PHP Fatal Error – yii\base\ErrorException

Class ‘Kendo\UI\Menu’ not found

Try adding this:




use \Kendo\UI\Menu



Then your code will be:




$topmenu = new Menu('topmenu');



How exactly did you add this - do you mean that you manually dropped the folder in, or did you install it via composer?

Edit: I checked the packagist site and noticed that KendoUI isn’t there, which means that you added it manually.

First, I would recommend not touching the @vendor directory at all unless you know exactly what you’re doing. Aka, let composer manage it.

(Take a look at the @vendor/composer/autoload_xxx.php files, and you’ll understand why your code doesn’t work)

Second, you’re going to have to figure out a way to include that package into Yii manually. I don’t know this off the top of my head, but you can start by reading this.

Edit 2: Looks like you just need to manually include their Autoload.php file. Simple enough, but again, I’d advise putting it somewhere outside the @vendor dir.