Search code examples
phpzend-framework2phpexcel

phpexcel in zend framework 2 Fatal error: Class 'PHPExcel_IOFactory' not found


I need to import data from an excel sheet and integrate PHPExcel in Zend framework 2.

I place the PHPExcel in vendor. Also I came to know after google that PHPExcel has no namespace so we can use the class as root class like \PHPExcel_IOFactory

But I am getting the following error:

Fatal error: Class 'PHPExcel_IOFactory' not found

Please help!


Solution

  • Manually placing a 3rd party library directory into the vendor without telling to your autoloader about the new namespace of the library and it's path is not enough.

    Try to use composer. Open the command line and simply type:

    $ cd /your/zf2/project/root
    $ rm -rf vendor/PHPExcel*
    $ php composer.phar selfupdate
    $ php composer.phar require phpoffice/phpexcel
    

    If you already have a system-wide composer installation:

    $ composer selfupdate
    $ composer require phpoffice/phpexcel