I haven't looked at RoR yet but your idea sounds cool. My main purpose is to be able to set the routes from within the app. So I won't have to add another - seperate - htaccess layer on top to get clean url's. That would also be a maintenance nightmare, as with each new route I would have to change the htaccess.
Clean URLs in MVC
Moderator: General Moderators
Indeed it will
Hopefully I have some time this week to get started with something.
I haven't looked at RoR yet but your idea sounds cool. My main purpose is to be able to set the routes from within the app. So I won't have to add another - seperate - htaccess layer on top to get clean url's. That would also be a maintenance nightmare, as with each new route I would have to change the htaccess.
I haven't looked at RoR yet but your idea sounds cool. My main purpose is to be able to set the routes from within the app. So I won't have to add another - seperate - htaccess layer on top to get clean url's. That would also be a maintenance nightmare, as with each new route I would have to change the htaccess.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
You can do that with the class provided in the code I linked to. I think the class is Http_PathInfo and there is code in "examples/pathinfo". You can give it custom mappings for different types of URLs so you only need one very simple rule in .htaccess (an example is provided). Not only that -- I made it so you can restart the mapping in the dispatched controller -- so you can provide basic mappings in the Front Controller and then append additional mappings in a dispatched Action Controller and have the mapper continue mapping the path where it left off. I have found that it greatly reduces the size of the FC map on sites that do lots of fancy paths. I essentially distributes the maps and lazy loads them with the corresponding Action Controller.matthijs wrote:My main purpose is to be able to set the routes from within the app. So I won't have to add another - seperate - htaccess layer on top to get clean url's. That would also be a maintenance nightmare, as with each new route I would have to change the htaccess.
(#10850)
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I still get code here an there from people and mold it in. I get ideas from the various frameworks around and simplify them by removing the bells, whistles and PHP5 stuff.matthijs wrote:The skeleton seems quite stable and mature already. And still developing. Do you still work together with the other developers in the current development?
I have never really treated it as a framework of the site and logo variety. It has always been minimal and controller-centric to show the basic ideas. I have thought of adding so other common code to it -- you know, a simple DB wrapper around PDO, a minimal ActiveRecord implementation, basic Access Control (with the proverbial sign-in page example), maybe Phemto, stuff like that. But it takes time to boil complex things down to something simple -- so it goes slow. I am always open to comments and contributions.
(#10850)
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
Re: Clean URLs in MVC
that sounds completely badass. i'll need help even understanding this but i think this is awesome and i have been wanting to put this into my framework and hopefully i can do it for my proof-of-concept.arborint wrote:Since I was mentioned -- you can get the "less simplified" version here that has an example using a class to map PATH_INFO values onto the Request. I think there is a .htaccess file included with the example. You an even do Rails style routes by providing your own map. And because the mapping is done on the Request object -- not inside the Front Controller -- you can mix both style URLs.matthijs wrote:For a project I'm using Arborint's (simplified) frontcontroller class (seen here). Using this class, one gets urls like
index.php?action=page
...
So that will make thing even more complicated. Any hints for directions I should look into?
i like the idea of mixing both (if i get lazy) so that's a nice feature. i'm totally gonna check this out sometime soon :thumbup:
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Clean URLs in MVC
Feel free to borrow, steal, mutilate, and improve however you heat desires.MrPotatoes wrote:that sounds completely badass. i'll need help even understanding this but i think this is awesome and i have been wanting to put this into my framework and hopefully i can do it for my proof-of-concept.
i like the idea of mixing both (if i get lazy) so that's a nice feature. i'm totally gonna check this out sometime soon :thumbup:
(#10850)
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
i definatly will. that is some pretty sick code. that is exactly what i needed. i already have a framework so the routing is what i want to play with. thank you for writing this code. it's perfect, shoot, i think it'll be great for SEO

once i figure out the forums i might just come over and try this
once i figure out the forums i might just come over and try this
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
did you ever figure this out? i'm deperatly trying to figure this out now and it's really gettin' to me
i'm trying some of the code from the skeleton but i can't seem to get it to work at all and i'm not even sure i know what's going on because what i need this might not be able to do
are there any more working tutorials on this?
i'm trying some of the code from the skeleton but i can't seem to get it to work at all and i'm not even sure i know what's going on because what i need this might not be able to do
are there any more working tutorials on this?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
yeah i can get it to work. as a matter of fact i made my own little one. i'm not sure how safe or even efficent it is right now but this is my code thusfar:
i think i can get this to work very easilly but i'd still like to use a map kind of a deal because i know my framework would get huge and it's easier to work with it instead of for it.
this one is also very very light. i don't know where any problems would arise with this. yet at least
i'm looking thru your code right now and seeing what i can take from that and add tohere and then i'll send it back your way and you can use it if you want. i'm just making mine so simple.
also, i can add query strings to the end of it but i can't put the prettyURLs at the end of a following querystring ('/query_string/thinger/<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>/?shizzy=thing/more/query/string/">
Code: Select all
echo '<a href="'. $_SERVER["SCRIPT_NAME"] . '/thing/2006/January/1st/param1/param2/param3/">date link</a><BR>';
echo '<a href="'. $_SERVER["SCRIPT_NAME"] . '/forums/off_topic/topic+name+is+this/">link to forums</a><BR>';
$url = $_SERVER['PATH_INFO'];
// remove all the slashes-------|
if (substr($url, 0, 1) == '/') $url = substr($url, 1);
if (substr($url, -1) == '/') $url = substr($url, 0, -1);
if ($url == '/') $url = '';
$url = explode('/', $url);
//------------------------------|
for ($j = 0; $j < count($url); $j++)
echo $j . ' ' . $url[$j] . '<BR>';
if ($url[0] == 'thing')
echo 'omg you got it';
else
echo 'you suck at life taters. go outside and give up';this one is also very very light. i don't know where any problems would arise with this. yet at least
i'm looking thru your code right now and seeing what i can take from that and add tohere and then i'll send it back your way and you can use it if you want. i'm just making mine so simple.
also, i can add query strings to the end of it but i can't put the prettyURLs at the end of a following querystring ('/query_string/thinger/<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>/?shizzy=thing/more/query/string/">
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Two things:
First, why are clean URLs better?
Second, I once ran across a website, coded in PHP, with clean URLs, but he did not use mod_wewrite. What he did was throw everything into a database and use a script he wrote to save everything into static files every time it was changed. It's not practical for anything more than a very small and sparsely updated website, but it is one way to do it..
P.S. I didn't read this entire thread so if someonen already figured it out, kudos.
First, why are clean URLs better?
Second, I once ran across a website, coded in PHP, with clean URLs, but he did not use mod_wewrite. What he did was throw everything into a database and use a script he wrote to save everything into static files every time it was changed. It's not practical for anything more than a very small and sparsely updated website, but it is one way to do it..
P.S. I didn't read this entire thread so if someonen already figured it out, kudos.