remenissions Posted February 26, 2013 Share Posted February 26, 2013 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... 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. 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 Link to comment https://forums.phpfreaks.com/topic/274949-php-ajax-scoping/#findComment-1415004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.