I have PHP project with the following vendors directory structure:
vendor
zendframework
zendframework
library
Zend
...
...
Cache
...
...
When I put the following line into autoload_namespaces.php everything is ok:
'Zend\\Cache' => $vendorDir . '/zendframework/zendframework/library/',
but this line doesn't work:
'Zend\\Cache' => $vendorDir . '/zendframework/zendframework/library/Zend/Cache/',
The error is:
Fatal error: Class 'Zend\Cache\Storage\Adapter\MemcachedOptions' not found
What's wrong with my code? How can I load only Cache module from zend framework? Why does it work if I specify whole library folder?
ZF1 classes have internal dependencies on other ZF classes. It's expecting the whole framework to be autoloaded. For every class not found error you get, you need to manually load that library too. Working through that list would be tedious, not impossible.
May I susggest an easier way forward:
Zend Framework 1.x can be installed with composer.
Add: "require": { "zendframework/zendframework1": "1.*" },
to your composer.json And do composer install from the command line. This will download zend framework and setup the library to autoload along with everything else composer is managing.
To get your zend framework app to use the composer autoloader you'll need to edit your applications index.php file and include the composer autoloader like so:
require_once realpath(APPLICATION_PATH . '/../vendor/autoload.php');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With