Hi all,

I'm trying to use the 3rd-party PHPExcel package in my ZF2 application. The 
distribution ships with the following
directory structure:

/Classes
    PHPExcel.php
    /PHPExcel
        [PSR-0 classes here]

In ZF1, I put the contents of the Classes dir in /library:

/library
    PHPExcel.php
    /PHPExcel
        [classes]

In my application/Bootstrap.php's _initAutoload() I simply added 
$loader->registerNamespace('PHPExcel') and the classes
were now available throughout my application. I should note that PHPExcel loads 
its own autoloader at the top of the
base PHPExcel class. I don't know if that was used or not, but no errors were 
tossed with the above configuration under ZF1.

ZF2's high regard for composer piqued my interest and I found that PHPExcel is 
available as a package on Packagist, so I
added it to my composer.json and after a `php composer.phar update`, I had a 
/phpoffice/phpexcel tree in /vendor.

Slick. Very slick. I can understand composer's appeal now.

I'm now expecting that I can add 'use PHPExcel;' in any file and start using 
the library, but the following code tosses
a class-not-found exception:

    $reader = PHPExcel_IOFactory::createReaderForFile('foo.xls');

However, when I use '\PHPExcel_IOFactory::', it works. Why do I need to use an 
absolute namespace reference, especially
when that class doesn't "live" in '\'?

What am I missing?

Thanks,

Brad

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to