I
I
Iu22016-11-15 17:43:05
PHP
Iu2, 2016-11-15 17:43:05

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

2 answer(s)
X
xmoonlight, 2016-11-15
@Iu2

I stop at a simple mistake and sit on it for half a day, how to fix it?
Option 3:
1. You do not understand English
2. You do not understand the terms displayed in the error due to poor knowledge of the language.
3. You do not understand the logic of your own code.
It is necessary to eliminate these "gaps" through understanding and memorization.
Here is a reminder on how best to do it so as not to get confused.

K
Kuzmina Maria, 2016-11-15
@orriole

>> 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 question

Ask a Question

731 491 924 answers to any question