Answer the question
In order to leave comments, you need to log in
How to build a PHP site architecture?
At the moment, I have moved from programs that output Hello World and simple queries from the database to mini-blogs with architecture, I divided everything according to the MVC idea:
1) Main page (to which all requests are redirected thanks to htaccess), to which controllers and database configs are connected with a router
2) The router that splits the URL redirects all requests to controllers with a ready URL, for example main_page/post/dekete/12
3) Controllers that receive data from the router and run the desired function
4) Model, the function calls the Delete model. php and politely asks to delete the post with id 12
That's it, but the problem is different:
1) When I write down the architecture in detail, even breaking each controller and function into a separate block and get to work with the hope of finishing everything in 1-2 hours (simple blog, add, remove, change, nothing else), I stop at a simple mistake and I sit on it for half a day, how to fix it?
Answer the question
In order to leave comments, you need to log in
I stop at a simple mistake and sit on it for half a day, how to fix it?Option 3:
>> 4) Model, the function refers to the Delete.php model and politely asks to delete the post with id 12
There should not be a Delete.php model, the model is used to store data and business rules applicable to it (for example, the "post" Post model) . And in the model, for example, there will already be a delete method that will delete the post from the database.
In general, try looking towards existing frameworks, for example Yii ( yiiframework.ru/doc/guide/ru/basics.mvc) , they already implement most of the standard functionality, including MVC.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question