These are chat archives for composer/composer

29th
Apr 2016
Chuk Shirley
@chukShirley
Apr 29 2016 18:42
A few months ago I made changes to the IbmiToolkit (https://github.com/zendtech/IbmiToolkit) to make it Composer friendly. I wanted users to be able to use the package as a composer dependency and as a regular "required" dependency from the global namespace (to preserve BC). The changes seemed to have worked until I tried to use the package as a Composer dependency with the Apigility skeleton app. Now it appears as though Composer is trying to autoload files from other packages using the IbmiToolkit's class map autoloader. Of course, those files aren't found within the IbmiToolkit. So I keep getting "File not found" errors. Can anyone point out what I've done wrong?
This repo demonstrates how I'm using the toolkit with the apigility skeleton app: https://github.com/chukShirley/apigility-toolkit-bug
...and here are the errors:
Notice: Undefined index: zendmvccontrollerpluginredirect in /www/apps/zf-apigility-skeleton/vendor/zendtech/ibmitoolkit/ToolkitApi/autoload.php on line 48

Fatal error: Uncaught exception 'Exception' with message 'File Not Found' in /www/apps/zf-apigility-skeleton/vendor/zendtech/ibmitoolkit/ToolkitApi/autoload.php:50 Stack trace: #0 [internal function]: {closure}('zendi18nviewhel...') #1 [internal function]: spl_autoload_call('zendi18nviewhel...') #2 /www/apps/zf-apigility-skeleton/vendor/zendframework/zend-servicemanager/src/Factory/InvokableFactory.php(93): class_exists('zendi18nviewhel...') #3 [internal function]: Zend\ServiceManager\Factory\InvokableFactory->createService(Object(Zend\View\HelperPluginManager), 'zendi18nviewhel...', 'Zend\\I18n\\View\\...') #4 /www/apps/zf-apigility-skeleton/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(934): call_user_func(Array, Object(Zend\View\HelperPluginManager), 'zendi18nviewhel...', 'Zend\\I18n\\View\\...') #5 /www/apps/zf-apigility-skeleton/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(330): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Array, 'zendi18nviewhel...', 'Zend in /www/apps/zf-apigility-skeleton/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 941
Chuk Shirley
@chukShirley
Apr 29 2016 20:47
I think I found the problem. My class map autoloader threw an exception if the file wasn't found. Thus, if a file was meant to be found with an autoloader that was registered after this one, my autoloader would throw an exception. Changing to
if (file_exists($myFile)) {
    require_once $myFile;
}