Zend_loader's autoloader deprecated in Zend framework 1.8

Source: Internet
Author: User
Tags autoload autoloader zend framework

Zend_loader'S autoloader has been deprecated in the upcoming Zend Framework version 1.8 and so you now get a notice if you use it:

Notice: Zend_loader: registerautoload is deprecated as of 1.8.0 and will be removed with 2.0.0; Use zend_loader_autoloader instead in/Www/ZF-tutorial/library/Zend/loader. phpOn line 207

Notice: Zend_loader: autoload is deprecated as of 1.8.0 and will be removed with 2.0.0; Use zend_loader_autoloader instead in/Www/ZF-tutorial/library/Zend/loader. phpOn line 186

Notice: Zend_loader: autoload is deprecated as of 1.8.0 and will be removed with 2.0.0; Use zend_loader_autoloader instead in/Www/ZF-tutorial/library/Zend/loader. phpOn line 186

(And so on)

This is because you have the lines:

require_once 'Zend/Loader.php';Zend_Loader::registerAutoload();

(Or similar) somewhere in your Bootstrap system.

The easiest solution is to change them:

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('App_');

Where 'app _ 'is the name of a directory on your include path that has classes within it that follow the Zend framework naming convention, so change it as appropriate and add more if you need them.

If you need generic autoloading ability, for instance because yourModelsDirectory is on your include path and you don't namespace your model classes, then add this:

$loader->setFallbackAutoloader(true);

You shoshould also add:

$loader->suppressNotFoundWarnings(false);

When in development mode as then the new autoloader will actually tell you what the syntax error is rather than showing you a white page

Now you shoshould go and readZend_loader_autoloaderDocumentation to learn how very useful it is!

Update: You shoshould also read Matthew's article on zend_loader_autoloader as it explains this all in detail!

This entry was posted on Thursday, 30th limit l 2009 at and is filed under Zend framework. you can follow any responses to this entry through the RSS 2.0 feed. you can skip to the end and leave a response. pinging is currently not allowed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.