Hey Matthew, Thanks for the explanation. I assumed since the error had "Zend_Exception" in it, that it was actually an exception being thrown.
Zend_Version::VERSION == '1.9.3' The code in the pastie is literally the only code that ever does anything with the autoloader. This is a new project, and other than some boilerplate controller code, this is the first few lines of code that have been typed. The only other modifications are adding the namespaces to the autoloader, using the built-in method through the application configuration: autoloaderNamespaces.cp = "CP_" autoloaderNamespaces.doctrine = "Doctrine_" It's also strange that the error is not being suppressed by the @ symbol. On Wed, Nov 4, 2009 at 8:57 AM, Matthew Weier O'Phinney <matt...@zend.com> wrote: > -- A.J. Brown <a...@ajbrown.org> wrote > (on Tuesday, 03 November 2009, 07:59 PM -0500): >> I'm trying to supress errors with the Zend Autoloader, but it's still >> throwing them. In this specific case, I'm dynamically ceating a class >> if it doesn't already exist. I'm calling suppressNotFoundWarnings( >> true ). >> >> Here's my code: >> >> http://www.pastie.org/682603 >> >> On line 13, I'm getting a Zend_Exception saying that CP/Form/Login.php >> not found and CP_Form_Login does not exist. Here's that line: >> >> if( @$autoloader->autoload( $class ) ) { >> >> even wrapping it in a Try/Catch doesn't catch the exception. The best >> part is that further down in the code, the class is still declared, >> and the code continues to run. >> >> the CP_ namespace is registered to the autoloader at bootstrap. (I >> confirmed this through debugging). > > You're confusing exceptions with errors. Zend_Loader_Autoloader does not > throw exceptions within its autoload() method (it's considered a bad > practice, and PHP itself behaves badly when it happens); this is why the > try/catch does not work. What's actually happening is that PHP's > include() function is raising a PHP warning when it can't find the > related file in question. > > What *is* odd to me is that the autoloader is not suppressing the errors > when you've specifically requested it do so. I've just tried this > locally with the following: > > > $autoloader->suppressNotFoundWarnings(true); > if (!$autoloader->autoload('Zend_Foo_Bar')) { > echo 'Not found'; > exit; > } > echo 'Found'; > > With the warnings suppressed, it works as expected; without, I get > the PHP warning, again, as expected. > > So, a few questions: > > * What version of ZF are you using? > * Can you provide *all* code indicating how you've configured the > autoloader? > * Is the "CP_" namespace registered with the autoloader? If not, do you > have another autoloader registered that would be handling it? > > Based on what you've presented, I have to assume that there's some other > configuration issue that's leading to the error. > > -- > Matthew Weier O'Phinney > Project Lead | matt...@zend.com > Zend Framework | http://framework.zend.com/ > -- A.J. Brown web | http://ajbrown.org phone | (937) 660-3969