zendframework / ZFTool

Utility module for maintaining modular Zend Framework 2 applications.
187 stars 102 forks source link

fail run zftool after phar create #137

Open userator opened 8 years ago

userator commented 8 years ago
userator@desktop:~ git clone https://github.com/zendframework/ZFTool.git ./zftool
...
userator@desktop:~ cd ./zftool
userator@desktop:~/zftool cd composer install
...
userator@desktop:~/zftool$ ./bin/create-phar
...
userator@desktop:~/zftool$ ./bin/zftool.phar 
PHP Fatal error:  Uncaught exception 'Zend\ModuleManager\Listener\Exception\RuntimeException' with message 'Could not find a valid ServiceManager for RoutePluginManager' in /home/kurshin/zftool/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php:202
Stack trace:
#0 /home/kurshin/zftool/vendor/zendframework/zend-eventmanager/src/EventManager.php(271): Zend\ModuleManager\Listener\ServiceListener->onLoadModulesPost(Object(Zend\ModuleManager\ModuleEvent))
#1 /home/kurshin/zftool/vendor/zendframework/zend-eventmanager/src/EventManager.php(143): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#2 /home/kurshin/zftool/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(129): Zend\EventManager\EventManager->triggerEvent(Object(Zend\ModuleManager\ModuleEvent))
#3 /home/kurshin/zftool/vendor/zendframework/zend-mvc/src/Application.php(264): Zend\ModuleManager\ModuleManager->loadModules()
#4 phar:///home/kurshin/zftool/bin/zftool.phar/zf.php(2): Zend\Mvc\Application::i in /home/kurshin/zftool/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 202
bierik commented 7 years ago

Same problem here using mac os 10.12.1:

PHP Fatal error:  Uncaught Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php:2
Stack trace:
#0 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-eventmanager/src/EventManager.php(2): Zend\ModuleManager\Listener\ServiceListener->onLoadModulesPost(Object(Zend\ModuleManager\ModuleEvent))
#1 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-eventmanager/src/EventManager.php(2): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#2 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(2): Zend\EventManager\EventManager->triggerEvent(Object(Zend\ModuleManager\ModuleEvent))
#3 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-mvc/src/Application.php(2): Zend\ModuleManager\ModuleManager->loadModules()
#4 phar:///usr/local/bin/zftool.phar/zf.php(2): Zend in phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 2

Fatal error: Uncaught Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php:2
Stack trace:
#0 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-eventmanager/src/EventManager.php(2): Zend\ModuleManager\Listener\ServiceListener->onLoadModulesPost(Object(Zend\ModuleManager\ModuleEvent))
#1 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-eventmanager/src/EventManager.php(2): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#2 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(2): Zend\EventManager\EventManager->triggerEvent(Object(Zend\ModuleManager\ModuleEvent))
#3 phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-mvc/src/Application.php(2): Zend\ModuleManager\ModuleManager->loadModules()
#4 phar:///usr/local/bin/zftool.phar/zf.php(2): Zend in phar:///usr/local/bin/zftool.phar/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 2

When I use the zftools in a ZEND skeleton (https://github.com/zendframework/ZendSkeletonApplication) it prints out some HTML

BasBastian commented 7 years ago

Old issue I solved recently. It is caused by choosing too liberal way of composer's dependency versioning. There were too many >= showing lack of experience on dependency management subject. If anythig would break, it will break with MAJOR. Selecting >= 2.2.2 as lower number boundary (that implicates there is no upper limit for version) causes some serious issues if anyone chnages their API upgrading MAJOR to let others know, that there are some major changes ( some of them might be not backward-compatible ).

TL; DR - just remove >= signs from ZFTools composer.json, remove vendor directory and perform composer update (and you might want to perform composer install as well) and bin/create-phar.

In your app consider as well some changes might break your app.

That fix is simple and imperfect - best choice would be for authors to change dependencies to most recent and yet compatible versions of zend-mvc and other components.

BasBastian commented 7 years ago

My bad. That actually wasn't the whole truth. It seems composer.json is lacking entry for zendframework or one of it's dependencies.

Short and pretty bad fix is to add zendframework as depedency. But then zftool.phar becomes 8MB file and generating it takes a while.

We have to inspect it and search for real problem.