MVCnPHP v4 Objective
One of the biggest gripes I get from people is that MVCnPHP requires an XML file for the configuration of the controller. The whole notion of convention over configuration is something they Ruby/Rails community has gotten right. Why should you have to edit an XML file just to add a new view or command to your system? You shouldn’t?
That said, I’ll be beginning work on MVCnPHP version 4 that will make this happen. The biggest impact is that the naming conventions of the views/commands will completely change. To illustrate let’s run through the process:
- Controller gets the following request:
http://www.example.com/index.php/someToken
- Controller looks at it’s internal configuration to see if it already knows what to do with someToken. If it does that means that someone has already requested that view/command and it will simply hand off execution to the associated view or command.
- If the Controller knows nothing about someToken, the Controller then looks in the view directory for someToken.php, if it doesn’t find it it then looks into the command diretory for someToken.php. If it doesn’t find any such file the controller returns a 404
- If the Controller finds someToken.php, the file is loaded, processed for any forwards and then the information is loaded into the Controller’s internal configuration for faster subsequent processing.
- After loading the data for someToken into it’s internal configuration, the Controller hands off execution to the associated view or command
This magical internal configuration will likely be the same format of the current XML configuration which would end up getting compiled into a PHP array just as it is today. This will minimize the total impact of this change and still allow for manual tweaking of the XML file which, while not necessary, could prove covenient.
I’d be interested in hearing thoughts or comments about the proposed solution and how it might be improved upon at all.