Page 2 of 3
Posted: Mon Jul 10, 2006 1:07 pm
by matthijs
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.
Posted: Mon Jul 10, 2006 2:21 pm
by Christopher
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.
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.
Posted: Mon Jul 10, 2006 3:36 pm
by matthijs
That's very very cool.
The skeleton seems quite stable and mature already. And still developing. Do you still work together with the other developers in the current development?
Posted: Mon Jul 10, 2006 4:02 pm
by Christopher
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 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.
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.
Re: Clean URLs in MVC
Posted: Mon Jul 10, 2006 4:55 pm
by MrPotatoes
arborint wrote: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?
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.
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:
Re: Clean URLs in MVC
Posted: Mon Jul 10, 2006 5:04 pm
by Christopher
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:
Feel free to borrow, steal, mutilate, and improve however you heat desires.

That's what that code is for. And if you come up with something cool post it and I wll borrow it back.

Posted: Mon Jul 10, 2006 7:01 pm
by MrPotatoes
will do. if i can figure it out.
this is something that i've actually wanted to do but i couldn't do because i didn't know where to start or how to do it. but if i add anything to it that makes it better or cooler or whatever i'l definatly post it. this is your code?
Posted: Mon Jul 10, 2006 7:06 pm
by Christopher
Yep, if you have questions about the code or design issues relating to controllers feel free to ask.
Posted: Tue Jul 11, 2006 8:58 am
by MrPotatoes
Posted: Fri Jul 28, 2006 2:36 pm
by MrPotatoes
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?
Posted: Fri Jul 28, 2006 4:34 pm
by Christopher
Can you get the example in "examples/pathinfo/" to work? If not can you tell me what is not working?
Posted: Fri Jul 28, 2006 4:41 pm
by MrPotatoes
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:
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';
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/">
Posted: Fri Jul 28, 2006 6:23 pm
by Christopher
MrPotatoes wrote: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/">
That is correct.
Posted: Fri Jul 28, 2006 7:49 pm
by MrPotatoes
lol, i purposly went thru that thing to make sure that it didn't have cuss words in it and yet i still missed that one. well, what can i say? that's how i alpha/debug my code lol
[edit] apparently i can't spell worth a damn tho *sad face*
Posted: Fri Jul 28, 2006 9:40 pm
by daedalus__
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.