punk_runner Posted January 5, 2011 Share Posted January 5, 2011 Okay, so I have managed to build a front controller using Apache's mod_rewrite to parse clean looking URL's and route them to the appropriate action-controller and method. But say that the user submitted an HTML form, like a registration form. The HTML form tag will redirect to something like www.domain.com/register/trial/90 which the front controller will route to: new $controller->$method($args); But how do I pass the form values stored in the $_POST global array to the controller/method? Do I just roll them up in a new array called formValues and pass them between the parens, or is there a better way? Stick them in a session? That seems sloppy.... Quote Link to comment https://forums.phpfreaks.com/topic/223447-front-controller-and-_post/ Share on other sites More sharing options...
trq Posted January 5, 2011 Share Posted January 5, 2011 Generally, your controller would have access to a Request object which would store all the data that comes with a users request. Quote Link to comment https://forums.phpfreaks.com/topic/223447-front-controller-and-_post/#findComment-1155077 Share on other sites More sharing options...
punk_runner Posted January 5, 2011 Author Share Posted January 5, 2011 Yes, the front controller has access to both the $_POST and $_REQUEST arrays just like any script that accepted a URL, but what is the prefered way to then pass that info off to the action controller, because it has to be rolled up and passed through to whatever method controls registration, right? Quote Link to comment https://forums.phpfreaks.com/topic/223447-front-controller-and-_post/#findComment-1155105 Share on other sites More sharing options...
trq Posted January 5, 2011 Share Posted January 5, 2011 I never mentioned the $_POST or $_REQUEST arrays. Assuming your attempting to build around the MVC pattern, generally, this pattern gives access to (and creates) both a Request & Response object. These objects are generally available to the controller. Well, the Request object generally is, while the Response object might actually be available through the View. Having said that, it's not always necessary, it's really just a design decision. Quote Link to comment https://forums.phpfreaks.com/topic/223447-front-controller-and-_post/#findComment-1155121 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.