Yii Framework Forum: Namespace For Kendo Ui Php Wrapper Class? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Namespace For Kendo Ui Php Wrapper Class?

#1 User is offline   djtech 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 11-November 10

Posted 09 May 2014 - 02:19 PM

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
0

#2 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 363
  • Joined: 23-July 09

Posted 11 May 2014 - 12:10 AM

Try adding this:

use \Kendo\UI\Menu


Then your code will be:

$topmenu = new Menu('topmenu');

We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#3 User is offline   amnah 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 23-February 13

Posted 11 May 2014 - 03:01 PM

View Postdjtech, on 09 May 2014 - 02:19 PM, said:

I have added KendoUI for PHP in my @vendors


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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users