-
Notifications
You must be signed in to change notification settings - Fork 816
Zend_Application tries to load ZendX_Application_Resource_FrontController during instantiation #564
Description
To ease up migration from ZF1 to ZF2, we use the component-based package. These packages are optimised (require_once
stripped, etc), and caused some warnings when being used at first. Most of these warnings can be prevented by extending the Composer include-path, section, also see: zf1/zend-application#2
One warning was more tricky to prevent though:
Warning: include_once(ZendX/Application/Resource/Frontcontroller.php) failed to open stream: No such file or directory in /workspace/project/vendor/zf1/zend-loader/library/Zend/Loader.php on line 134
Call Stack
# Time Memory Function Location
1 0.0018 289176 {main}( ) ../index.php:0
2 0.0842 4235072 Zend_Application->__construct( ) ../index.php:183
3 0.2636 4687488 Zend_Application->setOptions( ) ../Application.php:97
4 0.2637 4692048 Zend_Application->setBootstrap( ) ../Application.php:195
5 0.2778 4952568 Bootstrap->__construct( ) ../Application.php:340
6 0.2798 4987784 Zend_Application_Bootstrap_Bootstrap->__construct( ) ../Bootstrap.php:53
7 0.3312 5088528 Zend_Application_Bootstrap_BootstrapAbstract->hasPluginResource( ) ../Bootstrap.php:77
8 0.3312 5088864 Zend_Application_Bootstrap_BootstrapAbstract->getPluginResource( ) ../BootstrapAbstract.php:323
9 0.3378 5171664 Zend_Application_Bootstrap_BootstrapAbstract->_loadPluginResource( ) ../BootstrapAbstract.php:358
10 0.3379 5173216 Zend_Loader_PluginLoader->load( ) ../BootstrapAbstract.php:720
11 0.3513 5175504 class_exists ( ) ../PluginLoader.php:392
12 0.3513 5175896 spl_autoload_call ( ) ../PluginLoader.php:392
13 0.3516 5176144 Zend_Loader_Autoloader::autoload( ) ../PluginLoader.php:0
14 0.3516 5176496 call_user_func:{/workspace/project/vendor/zf1/zend-loader/library/Zend/Loader/Autoloader.php:124} ( ) ../Autoloader.php:124
15 0.3518 5176600 Zend_Loader_Autoloader->_autoload( ) ../Autoloader.php:124
16 0.3518 5176680 call_user_func:{/workspace/project/vendor/zf1/zend-loader/library/Zend/Loader/Autoloader.php:479} ( ) ../Autoloader.php:479
17 0.3518 5176880 Zend_Loader::loadClass( ) ../Autoloader.php:479
18 0.3518 5177288 Zend_Loader::loadFile( ) ../Loader.php:82
Suppressing this warning like this did NOT work:
$application = new Zend_Application(APPLICATION_ENV, '/path/to/application.ini'); //Already generates warning
$application->getAutoloader()->suppressNotFoundWarnings(true);
It appears that when the Zend_Application object is constructed, the invoked setOptions() makes it set a new Bootstrap object by default. During construction of this Bootstrap object, the following resources are loaded implicitly:
- ZendX_Application_Resource_FrontController //Does not exist, triggers warning!
- Zend_Application_Resource_FrontController
The specific order (ZendX_ first) is inherent to how the Module based Autoloader works. To be able to suppress the warning, this can be done like this (set $options AFTER instantiation):
$application = new Zend_Application(APPLICATION_ENV); //No options are set yet
$application->getAutoloader()->suppressNotFoundWarnings(true);
$application->setOptions($options = array('config' => '/path/to/application.ini'));
And extra flag to the constructor of Zend_Application would be nice though, will provide a PR for this.