Page 2 of 2

Re: Clean URLs from an application design perspective

Posted: Mon Aug 04, 2008 8:01 am
by allspiritseve
arborint wrote:
allspiritseve wrote:Ah. You probably know more about it than I do, then :D
Konstrukt is cool and Troels is a very, very smart guy!

You may want to take a look at HordeRoute. It is very powerful. Maybe overkill for you guys.
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.

Re: Clean URLs from an application design perspective

Posted: Mon Aug 04, 2008 12:28 pm
by Christopher
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:

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/>';
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.

Re: Clean URLs from an application design perspective

Posted: Wed Aug 27, 2008 9:08 pm
by allspiritseve
VirtuosiMedia, what did you finally ended up doing as far as clean urls go for your app?

Re: Clean URLs from an application design perspective

Posted: Thu Aug 28, 2008 10:25 am
by VirtuosiMedia
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.