Is http://dev.horde.org/routes/ what you're talking about? I took a look, and it does seem pretty powerful. I don't know though, I still think I prefer the distributed, logic-based routing from Konstrukt. But maybe my needs aren't complex enough yet.arborint wrote:Konstrukt is cool and Troels is a very, very smart guy!allspiritseve wrote:Ah. You probably know more about it than I do, then
You may want to take a look at HordeRoute. It is very powerful. Maybe overkill for you guys.
Clean URLs from an application design perspective
Moderator: General Moderators
- allspiritseve
- DevNet Resident
- Posts: 1174
- Joined: Thu Mar 06, 2008 8:23 am
- Location: Ann Arbor, MI (USA)
Re: Clean URLs from an application design perspective
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Clean URLs from an application design perspective
Yes, Horde Route is pretty powerful. Likewise the Konstrukt stuff is integrated so you have to use the full framework. Skeleton is loosely coupled, so can use many classes such as the router indepenetly. So you could do the following:
You can change the name of the parameters and to fancy things by passing a map array, but that is the basics using the defaults. So you can easily use your own controllers if you want.
Code: Select all
// create simple request class or use A_Http_Request
class MyRequest {
protected $request;
pubic function __contsruct() [
$this->request = $_GET;
}
pubic function set($name, $value) [
$this->request[$name] = $value;
}
pubic function get($name) [
return $this->request[$name];
}
}Code: Select all
// create request and 'router'
$request = new MyRequest();
$router = new A_Http_Pathinfo();
// set values in request from the clean URL
$router->run($request);
// show values for example URL "/foo/bar/param1/Hello world!/"
echo 'controller=' . $request->get('controller') . '<br/>';
echo 'action=' . $request->get('action') . '<br/>';
echo 'param1=' . $request->get('param1') . '<br/>';(#10850)
- allspiritseve
- DevNet Resident
- Posts: 1174
- Joined: Thu Mar 06, 2008 8:23 am
- Location: Ann Arbor, MI (USA)
Re: Clean URLs from an application design perspective
VirtuosiMedia, what did you finally ended up doing as far as clean urls go for your app?
- VirtuosiMedia
- Forum Contributor
- Posts: 133
- Joined: Thu Jun 12, 2008 6:16 pm
Re: Clean URLs from an application design perspective
For the site I was working on, I ended up storing the clean URL in the database and assigning a page controller to it. The site parsed the URL, looked it up in the database, and then fed it the appropriate controller. If the URL wasn't in the DB, it went to the 404 controller; if it was restricted to members only, it went to the members only controller. The site isn't running with the clean URLs yet, but you can check it out here if you like. In retrospect, there are a few things I would have done differently, like making sure the internal links change depending on whether the URLs are clean or not, but overall it seemed to work pretty well. However, on future projects, I might try using something like the Konstruct method, just to test it out and evaluate it.