Debugging Zend_Application errors

For programming and general questions on Zend Framework

Debugging Zend_Application errors

Postby musicalmidget on Wed Jun 22, 2011 10:16 pm

Hello all.

I'm having something of a strange time debugging some errors I'm experiencing in a new Zend Framework project I'm working on. Most of the time pages load fine, but from time to time I get a blank screen and several errors in the error log coming from Zend_Application.

Code: Select all
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Application.php on line 103
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Application->getEnvironment() /usr/share/zend-framework/1.11.7/Zend/Application.php:378
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 333
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Warning:  array_keys() expects parameter 1 to be array, null given in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 333
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. array_keys() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:333
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 333
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 251
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. Zend_Loader_Autoloader->getRegisteredNamespaces() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:346
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Warning:  array_keys() expects parameter 1 to be array, null given in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 251
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. Zend_Loader_Autoloader->getRegisteredNamespaces() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:346
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   7. array_keys() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:251
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 346
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 194
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. Zend_Loader_Autoloader->getNamespaceAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:355
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Warning:  array_key_exists() expects parameter 2 to be array, null given in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 194
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. Zend_Loader_Autoloader->getNamespaceAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:355
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   7. array_key_exists() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:194
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php on line 314
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   4. Zend_Loader_Autoloader::autoload() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   5. Zend_Loader_Autoloader->getClassAutoloaders() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:118
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   6. Zend_Loader_Autoloader->isFallbackAutoloader() /usr/share/zend-framework/1.11.7/Zend/Loader/Autoloader.php:364
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Fatal error:  Class 'Zend_Config_Ini' not found in /usr/share/zend-framework/1.11.7/Zend/Application.php on line 386
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/projects/sport-site/twig/public/index.php:0
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   2. Zend_Application->__construct() /var/www/projects/sport-site/twig/public/index.php:36
[Wed Jun 22 21:55:41 2011] [error] [client 127.0.0.1] PHP   3. Zend_Application->_loadConfig() /usr/share/zend-framework/1.11.7/Zend/Application.php:85


This problem is quite strange. The first entry in the error log is 'Trying to get property of non-object in /usr/share/zend-framework/1.11.7/Zend/Application.php on line 103'. Surely if this were the case however all requests to the application would fail rather than just some. Once the error occurs for the first time it happens on every request to any controller/view for a few minutes before seemingly starting to work again.

To make matters even stranger this error seems to go away when I switch out my Twig implementation for the standard Zend_View, yet the errors do not seem to be originating from Twig code. Interestingly I found a report of exactly the same problem on the Twig users forum but sadly no solution was available.

I wondered if possibly this might be a server configuration problem but I've uninstalled practically every PHP extension I could think of yet the problem still persists. I also don't have any kind of caching going on which would have been my next guess. I've even tried the code on another server and it still occurs.

In truth I'm actually not certain the bug is necessarily a bug in Zend_Application, rather Zend_Application has probably highlighted a problem elsewhere, either in Twig or in my server configuration. Since however all I have to go on are Zend Framework errors my first port of call is here. So, if anyone familiar with the inner workings of Zend_Application knows why this might be happening or could possibly assist me in getting to the root cause of the issue that would be much appreciated. I'm completely out of ideas myself.

Thanks
musicalmidget
 
Posts: 3
Joined: Fri Aug 28, 2009 9:30 am

Re: Debugging Zend_Application errors

Postby kkruecke on Wed Jun 22, 2011 11:33 pm

Why not put a breakpoint on that line?
kkruecke
 
Posts: 29
Joined: Thu Dec 03, 2009 7:36 pm

Re: Debugging Zend_Application errors

Postby musicalmidget on Thu Jun 23, 2011 2:25 pm

You'll have to forgive me but I'm not too well versed in debugging that way. Using var_dump($this, $this->_environment) at line 103 of Zend/Application.php does throw up some confusing results however.

$this obviously is an instance of Zend_Application in which the protected _environment variable has a value of 'development', yet the var_dump() of $this->_environment on the same line shows a value of null. I literally don't even know where to begin trying to trace a problem like that, especially as it seems to be an intermittent fault.
musicalmidget
 
Posts: 3
Joined: Fri Aug 28, 2009 9:30 am

Re: Debugging Zend_Application errors

Postby kkruecke on Thu Jun 23, 2011 7:15 pm

Download the Netbeans IDE for PHP: http://netbeans.org/downloads/index.html. It's free. Then download XDebug, a free 3rd party debugger http://www.xdebug.com/download.php that works with Netbeans. To determine which version of XDebug to down, just copy and copy the output of phpinfo() into the text box here: http://www.xdebug.com/find-binary.php, and it will tell you which version of XDebug to download and what changes to make to your php.ini

See also: http://wiki.netbeans.org/HowToConfigureXDebug

Then start Netbeans, File->New Project->Use Existing Source files. Finally, open the file, andsimply click on the line number of the line of code where you want to stop execution. The variables window at the bottom of the source file editor will show you their values.
kkruecke
 
Posts: 29
Joined: Thu Dec 03, 2009 7:36 pm

Re: Debugging Zend_Application errors

Postby musicalmidget on Fri Jun 24, 2011 4:09 pm

This appears to show the same result.
musicalmidget
 
Posts: 3
Joined: Fri Aug 28, 2009 9:30 am

Re: Debugging Zend_Application errors

Postby ahaithcox on Mon Oct 24, 2011 7:38 pm

Has anyone had any success at getting xdebug installed on an IBM iSeries (v5r4) server with Zend (PHP 5.2.14)? I have made multiple attempts with no luck getting it to work. I've tried to follow the directions at: http://wiki.netbeans.org/HowToConfigureXDebug, but have problems from the get go. I used the wizard that takes my phpinfo and give the suggested file to download and instructions. When I try to use the tar extract command, tar -xvzf xdebug-2.1.2.tgz, I've tried different variations of the switches, but no luck. I get a tar syntax error. I've extracted it with a window's util (winRar), but still no luck on the rest of the procedure.

Anyway, any help would be immensely appreciated.
ahaithcox
 
Posts: 43
Joined: Mon Oct 03, 2011 5:22 pm

Re: Debugging Zend_Application errors

Postby jezz on Wed Dec 14, 2011 4:27 pm

Has anyone been able to come up with a solution to this?
We're starting to see the problem more and more and clients are beginning to complain...

Any word from ZF devs?
jezz
 
Posts: 12
Joined: Wed Oct 28, 2009 8:59 am

Re: Debugging Zend_Application errors

Postby ahaithcox on Wed Dec 14, 2011 5:38 pm

I would still love to get my installation completed (see above). Any help?
ahaithcox
 
Posts: 43
Joined: Mon Oct 03, 2011 5:22 pm

Re: Debugging Zend_Application errors

Postby jschoenwolf on Thu Dec 15, 2011 9:19 am

check your public/index.php has it been changed from default? The application env constant is defined on lines 7 - 9:
Code: Select all
// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));


and the application.php constructor is set and called in lines 20 -26
Code: Select all
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();


for some reason this code is not being sent to the constructor of Application.php properly, looks like the same thing might be happening to your autoloader as well.
I wonder if your problem isn't related to "Twig" not registering correctly as a namespace for the autoloader.

check your
Code: Select all
autoloaderNamespaces[] = ""
in your application.ini

this is the only site I could find that might help http://www.rmauger.co.uk/2011/05/using-twig-with-zend-framework/

every thing here is pure guesswork, I hope it gives you some ideas
jschoenwolf
 
Posts: 239
Joined: Tue Aug 23, 2011 10:56 am

Re: Debugging Zend_Application errors

Postby jezz on Fri Jul 27, 2012 1:34 pm

I'd like to know if a solution has been found for this problem?
My guess is that the server setup itself is the culprit. The same code works just fine on my computer at home, but on the dev and live server, this error pops up randomly:

Notice: Trying to get property of non-object in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 333
Warning: array_keys() expects parameter 1 to be array, null given in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 333
Warning: Invalid argument supplied for foreach() in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 333
Notice: Trying to get property of non-object in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 251
Warning: array_keys() expects parameter 1 to be array, null given in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 251
Warning: Invalid argument supplied for foreach() in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 346
Notice: Trying to get property of non-object in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 194
Warning: array_key_exists() expects parameter 2 to be array, null given in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 194
Notice: Trying to get property of non-object in /domains/frameworks/zend/1.11/Zend/Loader/Autoloader.php on line 314
...

Refreshing the page makes the error go away, only to return moments later on a different page.
jezz
 
Posts: 12
Joined: Wed Oct 28, 2009 8:59 am

Next

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 2 guests