Here is how you add multiple namespaces to the ini

autoloadernamespaces.0 = "Zend_"    
autoloadernamespaces.1 = "Core_"
autoloadernamespaces.2 = "Models_"

Don’t forget the include path in the ini

includePaths.library = APPLICATION_PATH "/library/"

Hope that helps some
Terre



-----Original Message-----
From: Andrea Turso [mailto:trashofmast...@gmail.com] 
Sent: Monday, February 15, 2010 11:39 AM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Struggling with Resource Autoloading

That's funny, I'm stressed these days, I should rest a bit.

I solved this by editing the generated index.php to:

$application = new Zend_Application(
    APPLICATION_ENV,
    array(
        'config' => APPLICATION_PATH . '/configs/application.ini',
        'autoloaderNamespaces' =>
        array(
            'My_',
        ),
    )
);

Now I'm going to figure out how to set autoloaderNamespaces in my config.ini

-Andrea

On Mon, Feb 15, 2010 at 5:34 PM, Andrea Turso <trashofmast...@gmail.com>
wrote:
> Okay, I was wondering why now the autoloader can't handle includes for 
> my library.
>
> It keeps refusing to load my library/My classes.
>
> I don't get the point, when the autoloader could load My library 
> altough it couldn't find the services because they were in a different
directory.
>
> The weird thing is that it loads Zend files flawlessly.
>
> Go figure that out -.-' any illuminating suggestion that could help me 
> get out of this madness?
>
> Thanks,
> - Andrea
>
> On Mon, Feb 15, 2010 at 5:11 PM, Andrea Turso <trashofmast...@gmail.com>
wrote:
>> Thanks anyone for helping me out, but that was my fault, I 
>> inadvertently named the services folder as "service"
>> a small typo that required debugging all the application to catch. 
>> LOL
>>
>> Thanks again for the support
>>
>> - Andrea
>>
>> On Mon, Feb 15, 2010 at 12:45 PM, Andrea Turso <trashofmast...@gmail.com>
wrote:
>>> I started from scratch with ZF 1.10.1
>>>
>>> The issue still persist even after following your suggestions, how 
>>> could that be?
>>>
>>> - Andrea
>>>
>>> On Mon, Feb 15, 2010 at 5:30 PM, Matthew Weier O'Phinney 
>>> <matt...@zend.com> wrote:
>>>> -- Victor Farazdagi <vic...@afcomponents.com> wrote (on Monday, 15 
>>>> February 2010, 06:04 AM +0300):
>>>>> Andrea,
>>>>> First of - stuff you are trying to auto-load is pretty standard, 
>>>>> so I'd use Zend_Application_Module_Autoloader instead (check out 
>>>>> its source code - it loads models, services etc).
>>>>> So, having following Bootstrap.php is enough:
>>>>>
>>>>> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
>>>>> {
>>>>>     public function _initAutoload()
>>>>>     {
>>>>>         $moduleLoader = new Zend_Application_Module_Autoloader(
>>>>>             array('namespace' => '', 'basePath' => 
>>>>> APPLICATION_PATH)
>>>>>         );
>>>>>         return $moduleLoader;
>>>>>     }
>>>>> }
>>>>
>>>> The above is no longer necessary in 1.10 and up.
>>>>
>>>> If you create a new project in 1.10.0 and up, you'll get an extra 
>>>> configuration key:
>>>>
>>>>    appnamespace = "Application"
>>>>
>>>> What this means is that all resources under the default application 
>>>> directory expect a prefix of "Application":
>>>>
>>>>    Application_Model_Foobar
>>>>    Application_Service_Foo
>>>>    Application_Form_Bar
>>>>    etc.
>>>>
>>>> If you have an existing application and have upgraded to the 1.10 
>>>> series, simply add an "appnamespace" entry to your configuration, 
>>>> and specify the prefix you want to use -- which can also be a blank 
>>>> string as the above example did in the _initAutoload() method:
>>>>
>>>>    appnamespace = ""
>>>>
>>>> If you are using a version prior to 1.10.0, you will need to create 
>>>> a method such as the one depicted above.
>>>>
>>>>> (note: you'd need My for namespace, for me it's ok to rely on 
>>>>> appnamespace from configs/application.ini). Btw, check out the 
>>>>> appnamespace in your application.ini - if you generated your 
>>>>> project with zf - default value is "Application", which with my 
>>>>> empty namespace above gives me Application_Service_SomeService
classes.
>>>>>
>>>>> Second, you autoloader resource seems ok syntax and usage-wise - 
>>>>> autoloader namespace (My) gets appended with resource name (say, 
>>>>> Service), so it My_Service_SomeService should resolve..in theory 
>>>>> :) If issue is not with appnamespace, can you post your full 
>>>>> Bootstrap.php, and your index.php, so that resource init can be
reviewed in context?
>>>>>
>>>>> Andrea Turso wrote:
>>>>>
>>>>>     Hi people, I'm struggling to make Resource Autoloading work 
>>>>> with
>>>>>     Zend Framework 1.10.0
>>>>>
>>>>>     I created a blank project and started putting some code inside 
>>>>> a controller
>>>>>     created all the needed classes and configured my resources.
>>>>>
>>>>>     The application directory structure is pretty standard:
>>>>>
>>>>>     application/
>>>>>             `· services/
>>>>>             `· models/
>>>>>             `· controllers/
>>>>>
>>>>>     The index.php is the one generated by Zend_Tool.
>>>>>     I added these line in my application Bootstra.php
>>>>>
>>>>>             new Zend_Loader_Autoloader_Resource(
>>>>>                 array(
>>>>>                     'basePath'  => APPLICATION_PATH,
>>>>>                     'namespace' => 'My',
>>>>>                     'resourceTypes' => array(
>>>>>                         'service' => array(
>>>>>                             'path' => 'services',
>>>>>                             'namespace' => 'Service',
>>>>>                         ),
>>>>>                         'model' => array(
>>>>>                             'path' => 'models',
>>>>>                             'namespace' => 'Model',
>>>>>                         ),
>>>>>                     ),
>>>>>                 )
>>>>>             );
>>>>>
>>>>>     But when I run the application from my browser it keeps 
>>>>> spitting out a
>>>>>     fatal error
>>>>>     because it can't find the My_Service_SomeService class.
>>>>>
>>>>>     Warning: Zend_Loader::include_once(My/Service/SomeService.php) 
>>>>> [...]
>>>>>     /Development/Zend/Loader.php on line 146
>>>>>
>>>>>     Fatal error: Class 'My_Service_SomeService' not found in
>>>>>     
>>>>> /home/trashofmasters/Development/my/application/controllers/IndexC
>>>>> ontroller.php
>>>>>     on line 46
>>>>>
>>>>>     Ah, what a hell of headache... I always struggled with this 
>>>>> damned
>>>>>     autoloaders lol.
>>>>>
>>>>>     Any suggestions? Searching in the mailing lists didn't seem to 
>>>>> give
>>>>>     interesting results.
>>>>>
>>>>>     Thanks in advance,
>>>>>     Andrea
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Victor Farazdagi
>>>>>
>>>>> Blog      | http://www.phpmag.ru
>>>>> FourSee   | http://www.4cinc.com
>>>>> UMapper   | http://www.umapper.com
>>>>>
>>>>>
>>>>
>>>> --
>>>> Matthew Weier O'Phinney
>>>> Project Lead            | matt...@zend.com Zend Framework          
>>>> | http://framework.zend.com/ PGP key: 
>>>> http://framework.zend.com/zf-matthew-pgp-key.asc
>>>>
>>>
>>
>

Reply via email to