How thinkphp5.0 uses build.php to automatically generate the project directory

For example, if we want an admin directory,
we want to access
localhost/index.php/admin like this

Now thinkphp5 is installed to the specified directory

We found that there is a build.php file in the root directory, copy a copy to the application directory

open with notepad

The contents inside are:

return [  
    // 生成运行时目录  
    '__dir__'  => ['runtime/cache', 'runtime/log', 'runtime/temp', 'runtime/template'],  
    '__file__' => ['common.php'],  

    // 定义index模块的自动生成  
    'index'    => [  
        '__file__'   => ['common.php'],  
        '__dir__'    => ['behavior', 'controller', 'model', 'view'],  
        'controller' => ['Index', 'Test', 'UserType'],  
        'model'      => [],  
        'view'       => ['index/index'],  
    ],  
    // 。。。 其他更多的模块定义  
];  

Use your eyes to find where index is in this code

After you find it, you can modify it

For example, if you want to name the front desk home, just change it directly to home

Then we use the command to execute php, execute it in the root directory (key)

php think build

Switch to the application directory, you will find that there is an additional directory in it

how to visit

localhost.index.php/admin

In this way, you can modify the build.php in the application to create different sub-projects, such as api, admin, home.

Welcome to click the big penguin on the left

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326078038&siteId=291194637