Class yii\jui\DatePicker not found

I Installed composer successfully then i proceeded to install the extension "yii\jui" but first run this command for composer

$ composer global require "fxp/composer-asset-plugin:1.0.0-beta4"

This command to allow managing dependencies for (npm and bower) package through composer then i type to install the extension:

$ composer require --prefer-dist yiisoft/yii2-jui "*"

it finished successfully downloading the extension.

but after that i got two composer.json files one inside my project and the other at home directory

the one at home directoy includes only:

{

"require": {

"yiisoft/yii2-jui": "*"

}

}

and the other one in project includes everyting except “yiisoft/yii-jui”: “*”, after that i proceeded to try DatePicker widget in my project and it says “Class ‘yii\jui\DatePicker’ not found” with note that i used at the top of my page:

namespace yii\jui\DatePicker;

use yii\jui\DatePicker;

Hopefully anyone can enlighten me with the solution i will appreciate it, thanks.

The use statement should be used on the view in which you are using the widget, not the namespace, so if you are using both, it will not work. So just to be clear, the top of your view file should have:





use yii\jui\DatePicker;




The namespace on the DatePicker.php file should be:





namespace yii\jui;




This would have been set when you installed the extension, so you should not have to add it. The two should not appear in the same file together.

I did what you told me and still having the same issue Class "yii\jui\DatePicker" not found.

I want to know is DatePicker.php file under the vendor/yiisoft directory? Thanks

Thank you Mr. Evercode, i fixed the problem, it was because i made the manual download for the extension without using the composer, then i used the composer to download it and everything working smoothly. Thank you so much, God bless you :D.