In Yii 2.0 use thrid part non-namespace class Code Demo

This topic use PHPExcel as demo, show how to use non-namespace thrid part class in Yii 2.0 framework

 

{ Direct Use }

$objPHPExcel = new PHPExcel();

 

{ Error }

PHP Fatal Error – yii\base\ErrorException

Class 'frontend\controllers\PHPExcel' not found 

 

{ Solution }

$objPHPExcel = new \PHPExcel();

So for all non-namespace class, direct include file and use \ as start