Liquid Fire Posted July 24, 2008 Share Posted July 24, 2008 The most common url types i see with MVC frameworks are query string(index.php?c=controller&m=method&etc...) and segment(index.php/controller/method/etc...) but i am wondering what use it is to support query string type urls? The reason i ask is i am redesigning my php framework and i just see the point of support query string url type(most people are going to use rewrite on those type of url anyways). The downside to using query string type urls is that there is no way to tell which variables are meant to be passed as parameters for the method call or are just part of the $_GET array. is there any real benefit to support query string type urls that segment type urls does not have? Quote Link to comment https://forums.phpfreaks.com/topic/116399-mvc-and-url-types/ Share on other sites More sharing options...
keeB Posted October 10, 2008 Share Posted October 10, 2008 I don't think it should matter so much, nor should your framework be so tightly coupled with the way the data is coming in. You should have an implement an Interface that translates the Query String in to a data structure that you can understand down stream in your application. <?php class QueryString { //model object to be passed down stream private $controller; private $method; private $args = array(); // .. get methods .. // .. set methods .. } interface QueryStringTranslationService { // document how toQueryString should return a QueryString Model Object public function toQueryString($arr); } class GETQueryStringTranslationServiceImpl implements QueryStringTranslationService { public function toQueryString($arr) { //arr should be passed to here by application because it has determined you've received a $_GET request in some fashion $qs = new QueryString(); $qs->setController($arr['c']); $qs->setMethod($arr['m']); $qs->setArgs($arr['args']); return $qs; } } ?> The benefit of doing it this way is if there is some new trend of the month (which there always is for the web) and the URL is structured differently, you (or anyone using your framework) would be able to quickly swap out the GETQueryStringTranslationServiceImpl () for an implementation that more suits your needs. This gets back to another question of yours I just answered. In my opinion, there are the types of things frameworks need to provide. Quote Link to comment https://forums.phpfreaks.com/topic/116399-mvc-and-url-types/#findComment-661901 Share on other sites More sharing options...
Liquid Fire Posted October 11, 2008 Author Share Posted October 11, 2008 Yea, i decided to just add it in anyways, it is just built into the url_helper and it automatically know where or not to it is a segment or query url. Another question about urls that i see some frameworks do is they allow for url like: www.example.com/site/index automatically with an included .htaccess file. Now if you wanted something like above in my frameowrk, by default you would have to do: www.example.com/index.php/site/index Do you think it is required for a framework to provide this? My feeling is that if you want clean url(which is what that is for) that the user themselves should provide that functionality becuase i don't know what server they might be using. Quote Link to comment https://forums.phpfreaks.com/topic/116399-mvc-and-url-types/#findComment-662691 Share on other sites More sharing options...
keeB Posted October 11, 2008 Share Posted October 11, 2008 Do you think it is required for a framework to provide this? My feeling is that if you want clean url(which is what that is for) that the user themselves should provide that functionality becuase i don't know what server they might be using. That is the best assumption to make -- You cannot make assumptions Quote Link to comment https://forums.phpfreaks.com/topic/116399-mvc-and-url-types/#findComment-662950 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.