Using 3Rd Party Plugin Without Namespace

I want to use the latest version of jQuery File Upload in my Yii2 project. In order to do so I editid my project’s Composer file and installed jQFU so it sits in my vendor dir. I created an AssetBundle for it and it imports the necessary CSS and JS files just fine.

However it also needs a PHP file (UploadHandler.php) which is also in my vendor directory but it doesn’t have a namespace. How can I import this file?

I know I could copy that file inside my web folder and include it but then I would lose the possibility to auto-update file upload plugin with Composer.

What would be the best way to include the necessary PHP files from vendor dir?

I have created an extension yii2-password where I include (rather require) a presets.php file within the StrengthValidator class. Check if this helps you frame your code right.

Refer source and demo.

Thanks for your reply!

I just simply included the necessary files in one of my views like this:

require_once(Yii::$app->basePath . '/vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php');

It works fine. I have no idea why I didn’t think of this so far.


Also, check if you can directly use preconfigured @vendor alias


No, not working with the @vendor alias.

You need to translate alias into an actual path… like this:


    // or