[nycphp-talk] Some comments on the XML Talk
John Campbell
jcampbell1 at gmail.com
Thu Nov 1 16:42:21 EDT 2007
> I don't have an answer yet. I'm mostly just musing on some
> possibilities, and letting the ideas cook in my head for now. The tricky
> bit is figuring out how to design this so that there aren't a lot of
> confusing precedence rules for resolving conflicts between different
> mappings, while still allowing arbitrary mappings. For instance, one
> should be able to say that http://www.example.com/foo/bar/baz1 through
> http://www.example.com/foo/bar/baz100 are all database queries except
> for http://www.example.com/foo/bar/baz23 which is a static file, or that
> http://www.example.com/foo/baz1 through
> http://www.example.com/foo/baz100 are database queries unless there's a
> static 23.html file in directory /baz, in which case that should be used
> instead.
>
> It's possible I'm being too demanding. There may be a really clean 80/20
> cut somewhere, but so far I don't see it. I may need to build a few more
> applications along these lines first, just to see which features are
> really needed and which are just paint in the lilies. In any case, I
> don't have the answer yet, just the question.
Most frameworks these days do away with the direct mapping of the
request url to the filesystem. Zend/Django/RoR/Cake/ etc. all use the
notion of a "router" to parse the request and forward it to an object.
Your foo/bar/baz example is trivial to implement, because these
routers have all of the power of regexp.
You have also described mod_rewrite as confusing / inflexible. I find
that perplexing. Consider the following rewrite rules.
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
or even better:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
Since most people can figure out what these do without even referring
to the manual, I wouldn't consider it confusing. You should also
notice that all requests are sent to index.php, and so I don't
understand how it could possibly be any more flexible (there is plenty
of rope).
Below is a link to the docs for the Django router. IMO, it is the
cleanest example of url dispatching / routing. Whether or not you
like Python, it is worth reading because their solution is really
elegant.
http://www.djangoproject.com/documentation/url_dispatch/
Cheers,
John Campbell
More information about the talk
mailing list