I am using Composer to install packages for a PHP project. I have done this successfully for the Google V3 API; Composer installed the package correctly, sets up the Composer autoloader and I can reference the Google API classes by including the following statement in project source code:
require_once 'vendor/autoload.php';
I tried to do the same thing for some Zend 2 packages. Composer successfully downloads and installs the required Zend packages, but the Composer vendor/autoload does not work when I try to reference the classes in my code. Specifically, the Zend classes are referenced in the vendor/composer/autoload_namespaces.php file generated by Composer, but they are not referenced in vendor/composer/autoload_classmap.php, and Zend is also not referenced in vendor/composer/include_paths.php generated by Composer (unlike the Google API, which is referenced correctly).
Can anyone shed some light on why Zend is not working with the Composer autoloader, or is this expected behaviour and I need to use a different autoloading mechanism for Zend?
Thanks for the replies. I eventually discovered that the problem was caused because I was not using the fully qualified namespace to reference the Zend class, i.e.
instead of
I did not understand that the different libraries I am using via Composer use different approaches to class loading e.g. Composer generates entries in autoload_classmap.php for the Google Client API, but generates entries in autoload_namespaces.php for Zend and nothing in autoload_classmap, so I assumed I had done something wrong with the Composer installation.