Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4627582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:35:16+00:00 2026-05-22T03:35:16+00:00

Zend framework. I want to autoload my models classes inside models folder, from within

  • 0

Zend framework.
I want to autoload my models classes inside models folder, from within bootstrap class.
These models doesnt actually use any namespace (so I have Ex. User.php file’s class named User and so on..).

If I understood correctly I should use the Zend_Loader_Autoloader_Resource and I tried:

function _initLoaderResource() 
{         
    $resourceLoader = new Zend_Loader_Autoloader_Resource(array(                 
    'basePath'  => APPLICATION_PATH,//points to the "application" path where resides "models" folder
    'namespace' =>''       
    ));         

    $resourceLoader->addResourceType('models', 'models/');

} 

And I receive following ‘Zend_Loader_Exception’ message:

'Initial definition of a resource type must include a namespace' 

My questions are:

  • Is this the right way to autoload models?
  • How should I manage resource code that doesn’t follow Zend Framework coding standard?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:35:17+00:00Added an answer on May 22, 2026 at 3:35 am

    Actually you probably don’t want to use the resource autoloader for this, since (as you’ve discovered) it requires a namespace. The standard autoloader (which loads models from the include path) has an option setFallbackAutoloader which tells ZF that that autoloader should be used for any class not matching a namespace covered by another. So all you need to do is ensure your models directory is on the include path and set this option to true.

    You are probably already using the standard autoloader for loading the Zend classes, so you’ll probably want to modify your application.ini file to add your model directory to the include path, and then set the fallback option either in application.ini or in your Bootstrap class:

    protected function _initAutoloader()
    {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->setFallbackAutoloader(true);
    
        return $autoloader;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to echo an Image inside an Zend Framework View Script (files cant
The challenge: I want to modularize my library folder in my zend framework app.
I've got a little problem with Zend Framework Zend_Pdf class. Multibyte characters are stripped
I am working on implementing Zend Framework within an existing project that has a
Using Zend Framework I want to use controllers stored in a directory which is
I'm new to zend framework and I want to ask if is it possible
I'm writing a plugin for my Zend Framework app and want to do a
Zend Framework: I have the following url /base/url/[number]/[string] OR /base/url/action/controller/param/value I want in the
I want to make email templates in Zend Framework. For example, <html> <body> Dear
I want to upload an image with Zend Framework version 1.9.6. The uploading itself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.