I would like to ask some questions like router, MVC, CLASS, etc.

  mysql, question

I have asked similar questions before, but I didn’t explain my development method very clearly. Now I would like to continue to ask some questions I have seen recently. Let me first introduce my current development environment and some practices. I would like to ask experienced developers to help me improve my program ~
Mysqli(mariadb) plus php7 plus jquery3 are currently used for development, but I still don’t know much about the operation of router, MVC architecture, CLASS NAMESPACE, autoload and CURL, and I don’t know which is the right approach. From the last question to now, I have seen the implementation of many other YOUTUBE experts and found that everyone’s approach is different, which leads me not to know which approach is right and suitable for me.
Although I have tried many new writing methods, such as OOP mysqli connection, I still can’t think of how to replace my mind with the new ideas, because I know it may be difficult to maintain and let others cooperate.
First, I’ll explain my development method in detail, please have experienced greatly to teach me how to change the method smoothly.

At present, a web page is a PHP file. Each file will be followed by a PHP file (header.php, footer.php). footer.php mainly places js introduction, or JS required according to different file names, as well as various simple or complex jquery syntax files.
The files introduced by header.php are extremely complex. There is a folder containing many sql statements that will be classified. Each php inside will have a switch. According to which file path to introduce which sql statements, there is also a file containing many functions. Although there is a general plan to introduce this function into the right file, it is still far from class plus namespace. (html headers will also be introduced in this file)
One document is env.php, which will display the correct environment variable according to host.
SQL connect.php is currently introduced to every web page. Although every web page will need to connect to the database, this does not seem to be quite right, since I understand OOP.
There is a file that interacts with the back-end database, called update.php, which also uses switch plus type to find the right behavior according to the GET/type I gave. The front-end ajax takes a type to find the right request in update.php and does different things according to the type. SQL connect.php, necessary function and env.php will also be introduced into update.php.
There is a css.php that introduces all necessary css files, and if necessary, different css will be introduced according to different files.
I refer to the writing of the great god on github, for examplehttps://github.com/bramus/router、https://github.com/phalcon/mvc、https://github.com/php-curl-c …curl-class 、https://github.com/ThingEngin …… is a new world, but suffer from the current writing with their Not like ….

Therefore, I would like to ask how I can improve this arrangement, and even make it MVC and CLASS? My goal is to let people understand my code and work together. I believe this is not easy … but I believe Facebook was not written so smoothly at the beginning. There are too many places to change, but I don’t know where to start, starting with the easiest one to change …. I’d like to ask experienced people to give me great advice, thank you very much indeed! I will add from time to time!
Welcome to add l i n e friends (in my personal file). If you have questions, you will be given priority in dropping the web address.
I’m ready to improve my code ~

Question added:

  1. What is the difference between the introduction of namespace plus class and a bunch of function written in the same php and then introduced at one time? Suppose you have many function, some of which are back-end needs and some of which are front-end display needs, how would you place them?
  2. Sql connect is introduced into every page. What is the difference with OOP connect?
  3. Js management? Assuming that there are many click, mouse events in the same js file, will you write them in the same js file?
  4. I will place multiple ajax function in the same js file, and also use type to decide which ajax to look for, if it is you, Primetime: What Would You Do?.
  5. Css,js will you introduce all css,js in the beginning? Or how can it be effectively separated? To make it appear when it should, I use the switch method, Primetime: What Would You Do?.
  6. Is my update.php practice good? If it is Primetime: What Would You Do?
  7. In a php file, there are basically two files to be introduced, header.php and footer.php. Is this possible?

After looking at the technology you mentioned, I feel it has been out of date for a long time. …
1. First, let’s talk about the first problem. This is the problem of lazily loading autoload. It will only be loaded when this class is used. Otherwise, it will not be added. This can remove the unnecessary loading, and at the same time it will make the code less loaded and much better looking.
2.sql’s problem is the biggest, in fact, it should be used to connect sql, not connected, please refer to MVC pattern (of course, this MVC is outdated)
3.js is definitely a page and a js, and then there is a public.js or common.js with a public method.
4. In fact, this problem is one that MVC pattern can solve.
5. Same as above, refer to MVC pattern
6. I have never seen this kind of SAO operation, which uses router to decide which function in which file to access.
7. Not very usable. It is an autoload problem. There has been a solution for a long time. composer should know about it.