remenissions Posted February 26, 2013 Share Posted February 26, 2013 (edited) Hi, I was wondering what everyones thoughts would be to a command handler I wrote to handle my php. I'm not sure if this is a good idea or not. I have one file called commandHandler.php which looks something simular to this, just writing this simply to show what I'm doing. commandHandler.php <?php switch($_POST['cmd']) { case "login": require("login file"); Login::html(true); break; } ?> loginHandler.php class Login { public static function html($form) { /* -Grabs the fields in either ajax or form type- */ } } Basically I'm handling most php files this way, simply because I want to keep my php written in classes to keep it neat and organised. Any thoughts on whether this is a good or bad idea? Also just to throw it out there, the $_POST['cmd'] goes through filtering and parsing before it enters the switch statement. Basically it is parsed like this: $_POST['cmd'] == "command arg1 arg2 arg3 arg4"; //etc... Edited February 26, 2013 by remenissions Quote Link to comment https://forums.phpfreaks.com/topic/274949-php-ajax-scoping/ Share on other sites More sharing options...
trq Posted February 26, 2013 Share Posted February 26, 2013 This is the basics of a front controller. This pattern is used a lot. Quote Link to comment https://forums.phpfreaks.com/topic/274949-php-ajax-scoping/#findComment-1415002 Share on other sites More sharing options...
remenissions Posted February 26, 2013 Author Share Posted February 26, 2013 Ok thank you very much I just wanted to make sure Quote Link to comment https://forums.phpfreaks.com/topic/274949-php-ajax-scoping/#findComment-1415004 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.