After two days of work on ritho-web I’ve finished the MVC engine. I’d some previous ideas about the implementation of the engine from some websites, so it was easy to implement it. The engine have the following elements:
- Models: The models are used by the controllers as the data representation in the application. Actually there aren’t any model, but I’ll add as soon as I have the database implementation ready.
- Views: The views gets all the data processed by the controlled and generates the html output. They do it using the Template class, that gets an html template and replace the php vars included by its values, generating the html output.
- Controllers: The controller process a request and display the html output through the views. To process the request we have to: initialize the controller (including get the configs and the initial models), process the get or post method (which process, if needed, the models and generate the view to show) and display the generated view.
This implementation makes easy to add new views and controllers to process the action requested.
In order to use this engine we have to match at index.php the page requested with the controller that process this action. To make it posible we have to configure Apache to redirect all the request to index.php and, at index.php, check the $_SERVER[‘REQUEST_URI’] variable to know the page that the user is requesting and generate and run the controller tat handle this request.
The next step is to add the database access to the app. I have to think the exact way I’m going to implement this, because I want to make it flexible but optimized to each database engine, so I’ve to think the methods to implement in the DB parent class and in each child (one for each engine) and which queries can be in the database class to use by all the application and which ones have to be implemented directly by the caller method. I’ll keep you informed.