views:

334

answers:

1

Hi all,

I'm using the Zend Framework for my website, and just created a special module "api" to create... Well, an API.

Now, I have a lot of controllers in my module and I'd like to create subdirectories in this controllers directory in order to "tidy" it. My new structure would be something like this :

 - controllers/
 - controllers/contents/[controllers]
 - controllers/users/[controllers]
 - controllers/misc/[controllers]

However, I find myself totally unable to find what kind of urls and redirections using Zend_Controller_Router_Route could map to these controllers. Is it possible to do this somehow or should I just go back to the normal structure and put all my controllers in the same directory ?


I tried using the separators _ as suggested by smack0007 and as it seemed logical given how Zend Framework usually refers to subdirectories, but I got an error.


Edit : Removed the long error text as it was not related to the question since it was only a problem because I didn't use the propre case, believing I had to put an uppercase to the first letter of the directory. All works well now.

+1  A: 

I've done this in project back in the 1.5 version but I don't know if it will work anymore.

You have to prefix your controllers with "{FOLDER}_" and then use the full name in the url.

So in your case you would have a controller named:

contents_FooController

and a route:

/contents_foo/index
smack0007
Well it seems to me that this behaviour has been changed : I try to access to a controller Contents_FooController in a subdirectory "contents" of the "controllers" directory (in the default module), it tells me it can't find it. I'll edit the question information with this data.
Hugo
Try one thing for me: Rename the "contents" folder to "Contents"
smack0007
Let me correct what I was just saying, it does work (edited the wrong directory, sorry), thank you ! I made a mistake by believing I had to put the name of the directory in uppercase, thanks a lot for the help.
Hugo