Form/Models autoloading problem

3 messages Options
Embed this post
Permalink
Simeon Goranov-3

Form/Models autoloading problem

Reply Threaded More More options
Print post
Permalink
Hello,
I'm trying to autoload form or a model inside my application directory.
I've got:

application/models/News.php
where Default_Model_News is defined

In the Bootstrap.php I have following:

    protected function _initAutoload()
    {
    $loader = Zend_Loader_Autoloader::getInstance();
    $loader->registerNamespace('myLibs');
   
        $moduleLoader = new Zend_Application_Module_Autoloader(array(
            'basePath' => APPLICATION_PATH,
            'namespace' => '',
        ));

        return $moduleLoader;
    }

When I try to create an object, for example:

$model = new Default_Model_News();

I recieve:

Fatal error: Class 'Default_Model_News' not found

Do you have any idea what I'm missing ?

Regards,
S.G.

weierophinney

Re: Form/Models autoloading problem

Reply Threaded More More options
Print post
Permalink
-- Simeon Goranov <[hidden email]> wrote
(on Thursday, 05 November 2009, 05:23 PM +0200):

> Hello,
> I'm trying to autoload form or a model inside my application directory.
> I've got:
>
> application/models/News.php
> where Default_Model_News is defined
>
> In the Bootstrap.php I have following:
>
>     protected function _initAutoload()
>     {
>     $loader = Zend_Loader_Autoloader::getInstance();
>     $loader->registerNamespace('myLibs');
>    
>         $moduleLoader = new Zend_Application_Module_Autoloader(array(
>             'basePath' => APPLICATION_PATH,
>             'namespace' => '',

Either change the namespace value to 'Default', or remove the 'Default_'
from the class names (I'd change the namespace value, personally).

>         ));
>
>         return $moduleLoader;
>     }
>
> When I try to create an object, for example:
>
> $model = new Default_Model_News();
>
> I recieve:
>
> Fatal error: Class 'Default_Model_News' not found
>
> Do you have any idea what I'm missing ?
>
> Regards,
> S.G.
>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
Simeon Goranov-3

Re: Form/Models autoloading problem

Reply Threaded More More options
Print post
Permalink
Thanks !

В 10:51 -0500 на 05.11.2009 (чт), Matthew Weier O'Phinney написа:

> -- Simeon Goranov <[hidden email]> wrote
> (on Thursday, 05 November 2009, 05:23 PM +0200):
> > Hello,
> > I'm trying to autoload form or a model inside my application directory.
> > I've got:
> >
> > application/models/News.php
> > where Default_Model_News is defined
> >
> > In the Bootstrap.php I have following:
> >
> >     protected function _initAutoload()
> >     {
> >     $loader = Zend_Loader_Autoloader::getInstance();
> >     $loader->registerNamespace('myLibs');
> >    
> >         $moduleLoader = new Zend_Application_Module_Autoloader(array(
> >             'basePath' => APPLICATION_PATH,
> >             'namespace' => '',
>
> Either change the namespace value to 'Default', or remove the 'Default_'
> from the class names (I'd change the namespace value, personally).
>
> >         ));
> >
> >         return $moduleLoader;
> >     }
> >
> > When I try to create an object, for example:
> >
> > $model = new Default_Model_News();
> >
> > I recieve:
> >
> > Fatal error: Class 'Default_Model_News' not found
> >
> > Do you have any idea what I'm missing ?
> >
> > Regards,
> > S.G.
> >
>