Import 3rd Party files in Yii 2.0 not working

Hi there,

i want to update from Yii 1.1 to Yii 2.0 and i’m still in the beginning of migrating the code …

At this moment i have big blocker for me so i hope somebody can help me out.

I need to import and work with several 3rd party librarys in my application which i cant include right now.

For example, i’m working in this file: app\components\generators\ReportGenerator.php and i want to include a file from: app\vendor\phpdocx_pro\classes\

My code looks like:

require_once(__DIR__ . '/../../vendor/phpdocx_pro/classes/');

$docx = new CreateDocx();

When i run the code i got the following error:

“PHP Fatal error: Class ‘app\components\generators\CreateDocx’ not found in …”

Can somebody please told me how i could include code from outside the given namespace?

Thanks a lot for help and have a great day!

$docx = new \CreateDocx();

Hey samdark! Thanks fpr the quick answer. Works! :)

Could you give me a link or sth like this where i can found a bit of background why there is a need for the "\" ;)