448191 Posted September 15, 2006 Share Posted September 15, 2006 Just wondering, what do you, if you use a standard convention use for format when passing variables though get, transformed by mod_rewrite?I'm using a single $_GET index called 'route', wich can be used for all controller classes.... It's formatting of this string that I'm wondering about...I now just use this style:http://somesite.com/controllerclassname/controllermethodname/parameterkey1/parametervalue1 etc..But I'm thinking something more along the lines of:[quote]?route=controllerclassname/controllermethodname/[parameterkey1:parametervalue1]/[parameterkey2:parametervalue2][/quote]Rewritten to:http://somesite.com/controllerclassname/controllermethodname/parametervalue1/parametervalue2/While still having the keys available in $_GET.. Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/ Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 On the other hand, I might as well use regular request uri, (rewritten when requested of course) because this way I'm exposing my navigational variables in the source just as obviously. Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92252 Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 either use the rewrite rules to do it for you, or you can follow suit from the likes of Zend Framework's default Router object, which I'm hazarding a guess you are already doing?[code]<?php$request = substr($_SERVER['REQUEST_URI'], 1);if (strrpos($request, '/') === strlen($request) -1) $request = substr($request, 0, -1);$request = explode('/', $request);$vars = array();for($i = 0, $c = count($request); $i < $c; $i++){ $vars[$request[$i++]] = $request[$i];}var_dump($vars);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92328 Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 Currently, I'm using this:[code]<?php// Analyze route$routeArr = explode('/',self::getRoute());//Route accepted format: controller/method/parameterIndexName/parameterIndexValue/etc,etc$className = array_shift($routeArr).'_Controller';$methodName = array_shift($routeArr);if($methodName === null){ $methodName = 'index';}//Assemble parameter array:$parameterArray = array_compose($routeArr,true);?>[/code]array_compose being an udf composing an associative array from a numeric one.all getRoute basicly does is a simple explode.The problem I have with this, is that it causes long URIs.I think I'm just going to abandon the whole 'passing associative array' concept, since the order of elements is already under constraints for determening the controller and action (method). Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92331 Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 Depends how much data you need to pass via uri, if they are 'too long' perhaps you need to seek other methods of transfer.also, on side note, my snippet creates a pseudo $_GET array:[code]http://www.example.com/foo/bar/boo/far[/code]will create an array:[code]array(2) { ["foo"]=> string(3) "bar" ["boo"]=> string(3) "far"}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92366 Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 Mine does the same, except that it uses the first value as controller, the second as method and parses what's left into an associative array for the parameter. Plus it supports setting default values for keys without values.Example:article/read/id/1/title/blah-blahblah/editAction: Article_Controller::read(array('id'=>'1','title'=>'blah-blahblah','edit'=>true)); Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92376 Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 Identical to ZF's. Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92404 Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 [quote author=Jenk link=topic=108144.msg434884#msg434884 date=1158328497]Identical to ZF's.[/quote]Then that is absolutely an utter and complete coincidence. I've never laid eyes on a single line of ZF. I guess I'm just that good :P (joking of course).I take a look at it now though. :) Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92437 Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 It's a very nice framework (preference plays a big part in any/all frameword decisions.) Not complete yet of course, and I anticipate there will be a price when it is finally released. Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92445 Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 [quote author=Jenk link=topic=108144.msg434927#msg434927 date=1158332636]It's a very nice framework (preference plays a big part in any/all frameword decisions.) Not complete yet of course, and I anticipate there will be a price when it is finally released.[/quote]Luckily I wasn't intending on buying it, nor using it at all for that matter (ya'll know there's a difference :-X). I was just planning on borrowing some idea's. :-X Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92481 Share on other sites More sharing options...
448191 Posted September 15, 2006 Author Share Posted September 15, 2006 I'm not so sure Zend is going to ask anything for it.This [url=http://framework.zend.com/contributors]collection of übergeeks[/url] have volunteerd. So it's not likely to become a commercial product.I'm thinking they'll GPL it, hoping this framework will become very popular, php5 piggyback riding off it's popularity to finally gain dominance over php4.Edit:Ok, not GPL but free none the less:http://framework.zend.com/license/zend-framework-1.0http://framework.zend.com/license/new-bsdDoes it say anywhere I can't copy and modify parts of it? ::)Probably not, I won't bother reading any of it then. Kidding, mods please don't kill me...:PIt would seem class name/location conventions and uri processing aren't the only things my custom framework in devleopment has in common with ZF. The caching systems are also very similar. Except mine supports chunked caching, a feature I couldn't spot in ZF, and ZF's caching engine has memcache support when available.Also I noticed some logic where objects were being serialized for caching? What is that about? I'ts not output caching, I wonder in what situations that could be usefull..I'm not really familiar with memcache, does it also allow for managing output caching in memory, or is it purely a resultset caching thing? Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-92537 Share on other sites More sharing options...
Jenk Posted September 18, 2006 Share Posted September 18, 2006 I don't know, I've not used it nor looked into it :) Quote Link to comment https://forums.phpfreaks.com/topic/20837-uris-modified-title-the-zend-framework/#findComment-93858 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.