Added by Christopher Thompson, last edited by Matthew Weier O'Phinney on Sep 20, 2006  (view change)

Labels

 
(None)

Zend Framework: Action Controller Directory Tree Component Proposal

Proposed Component Name Action Controller Directory Tree
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Action Controller Directory Tree
Proposers Christopher Thompson
Revision 1.1 - 22 June 2006: Created. (wiki revision: 6)

Table of Contents

1. Overview

Allow Action controllers to be organized in a directory tree.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • Change allowable ":controller" parameter to allow path separators
  • Change Dispatcher and possibly other classes to support Action controller paths
  • Protect against security risks of allowing this additional capability

4. Dependencies on Other Framework Components

  • Zend_Controller_Dispatch
  • Zend_Front * possibly
  • Zend_Router * possibly
  • Zend_RewriteRouter * possibly

5. Theory of Operation

The change would allow syntax in the ":controller" parameter to allow Action controllers in sub-directories within the "controllers" directory to be referenced. I propose that the character "_" be allowed in the ":controller" parameter and that it be converted to the path separator character in the same way that Zend::loadClass() does. This will be consistent with the current formatting scheme. I do not propose that other characters be allowed in sub-directory names – only [a-zA-Z0-9] – but that option is possible.

6. Milestones / Tasks

zone: Missing {zone-data:milestones}

7. Class Index

N/A

8. Use Cases

Given the code:

The URL:

www.mydomain.com/subdir_path_example/bar/

Would dispatch the Action controller in:

/path/to/my/controllers/subdir/path/ExampleController.php

9. Class Skeletons

N/A

I like the idea, maybe you could look into creating a patch for RewriteRouter that adds this support? I don't see it being a whole seperate class really?

This is proposed at a change mainly to the Dispatcher, but some other changes may be necessary (based on my making this change on the 1.1 code a while back)

Like it, but I would allow either _ or - to divide directories. Some people prefer dashes in the URLs.

www.mydomain.com/subdir-path-example/bar

It's a pretty simple proposal, really, so I don't have anything more substantive to contribute.

I'm more interested in a way to specify the sub directory for a route, for example a url of http://example.org/admin/controller/action/params could be configured to look in controller_dir/admin/ControllerController.php.

As for your proposal, I don't mind it being implemented, but I would like to be able to disable it too.

I am looking for this ability too Nikolai.

URLs of the form:

http://example.com/members/XX/YY
http://example.com/admin/XX/YY

"look better" than

http://example.com/members_XX/YY
http://example.com/admin_XX/YY

(IMO!)

I just have to agree to Rob and Nikolai.

With Slashes instead of Underscore we could also define the areas more clearly.

The only part of this proposal that I see as beneficial is the ability to have the controllers themselves within a tree. As it is, I believe this would only require:

1. Creating (rewrite) router rules that map a controller to a valid class name: :controller => Some_Subdir_Class
2. Modifying the dispatcher's formatName() to allow the '' in names; thus, class names could indicate controllers in a tree.

If this will resolve the issue, I am willing to accept this proposal.

Zend Comment

We are accepting this proposal, using Matthew's second point. Matthew will do the change (one line change), and it will be incorporated into the MVC refactoring when it is released.

And whats happened?