Home > Backend Development > PHP Problem > How to use PHP to create the general process of MVC framework

How to use PHP to create the general process of MVC framework

慕斯
Release: 2023-03-10 19:50:01
Original
2395 people have browsed it

The previous article introduced you to "How to use the select method of the Model class in PHP? 》, this article continues to introduce to you how to use PHP to make an MVC framework. The general process has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use PHP to create the general process of MVC framework

PHP Advanced Head Start-MVC Framework

1、

mvc

model

vi ew

controller

2. psr specification.

psr1: Basics Programming specifications

psr2: Coding style specifications

psr3: Log interface specifications

psr4: Automatic loading specifications

3. Naming Specification

The file name and the class name are the same (big camel case principle) IndexController

The namespace name and the folder name are the same (all lowercase).

4. Single entry (simple routing)

1

2

3

index. php?m= index&a= index

pathinfo index. php/ index/ index

spl_ autoload register (__ autoload)

Copy after login

5. Framework directory structure

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

app

     model

            UserModel . php

     view

     controller 

            Controller . php

            UserController . php

config

     config. php

vendor

     1ib

          framework

            src

            Model . php

            Page. php

            Tp1.php

        public

             CSS

                

js

                

fonts

  

              editor

             cache缓存.

Copy after login

6. Namespace mapping

1

2

3

model=>app/ model

controller =>app/controller/

framework =>vendor/lib/framework/ src

Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to use PHP to create the general process of MVC framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template