Search code examples
zend-frameworkzend-framework2phpexcel

Loading PHPExcel library in Zend Framework 2 only in current action


I would like to use PHPExcel library in a zend framework 2 project. But I don't want to load it for the overall project, just in one particular action. How can I do this?


Solution

  • If your PHPExcel library is load by composer.phar yo can access the class through:

    $objPHPExcel = new \PHPExcel();
    

    else, you must include path of your library before use :

    /** Include path **/
    ini_set('include_path', ini_get('include_path').';<relative directory path>/');
    
    /** PHPExcel */
    include 'PHPExcel.php';
    
    $objPHPExcel = new PHPExcel();