Download multiple application extensions according to the official thinkphp6 document, and create several applications, but do not know how to implement the in-app routing configuration, add route in the route\app.php directory, but after access, the message is not found the controller. Route \app.php: route\app.php: route\app.php: route\app.php: route\app.php: route\app.php After the in-app route file is created, it is found that the in-app route file does not take effect, and there is no relevant information in the official documentation. It is found that the url_lazy_route (delayed parsing) in config/route.app needs to be changed to true, so that the in-app route takes effect.

1. Install the PHP7.3 development environment and configure PHP environment variables

2. Download the Composer tool and install it

3. Download ThinkPHP6 using Composer

Composer create - project topthink/think = 6.0 * tp6

4. Install the ThinkPHP6 Multi-application extension

composer require topthink/think-multi-app

5. Delete all files in the app directory (i.e. delete single app files)

6. Create applications as required, such as admin(background administration), Index (home page), common (common base class)

php think build admin
php think build index
php think build common
Copy the code

7. Go to config/route. PHP, enable route delay parsing, and modify the cause

Tp6 application mode of route design took me about two days to understand, in fact, the core or hierarchy problems, such as opens the application model, and then a new route in the application directory folder, under this folder to create routing file to configure the affirmation is not enough, because tp6 is synchronous parsing by default, So you need to in the project more directory under the config directory of the route in the configuration file open delay resolution, this way is simple, when you visit: domain name/application/controllers/method, your application directory routing file packet routing rules should not only take a application name to the group, but with the controller to make the name of the group

Copyright notice: This article is originally published BY CSDN blogger “Daoke_awin”. It is subject to CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement. The original link: blog.csdn.net/alisen169/a…

'url_lazy_route'= >true.// Change false to true
Copy the code

To change the default app to admin, go to config/app.php and change ‘default_app’ => ‘index’ to ‘default_app’ => ‘admin’.

9. Create a user controller in the controller of the admin application. Create a testUser in the user controller and return testUser

php think make:controller admin@user

public function testUser()
{
    return 'testUser';
}
Copy the code

10. Create a route for it. In the app\admin directory, create route\app.php and enter the route configuration


      

use think\facade\Route;

Route::get('test'.'user/testUser');
Copy the code