Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between the multiple applications of TP6 and TP5

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the difference between the multi-application of TP6 and TP5". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is the difference between the addition of 'multiple applications' in ThinkPHP6 and ThinkPHP5?

First of all, take a look at the directory structure of the ThinkPHP6 official manual on multi-applications:

├─ app application directory │ ├─ index main application │ │ ├─ controller controller directory │ │ ├─ model model directory │ │ ├─ view view directory │ │ ├─ config configuration directory (priority) │ │ └─... More class libraries directory │ ├─ admin background application │ │ ├─ controller controller directory │ │ ├─ model model directory │ │ ├─ view view directory │ │ ├─ config configuration directory (priority) │ │ └─. More class libraries directory │├─ public WEB directory (external access directory) │ ├─ admin.php background portal file │ ├─ index.php entry file │ ├─ router.php quick test file │ └─ .htaccess for apache rewriting │├─ config application configuration directory │ ├─ index Index application configuration │ └─ admin admin application configuration │├─ view view directory │ ├─ index index application view directory │ └─ admin admin application view directory │├─ route route definition directory │ ├─ index index application route definition directory │ └─ Admin admin application routing definition directory │├─ runtime runtime directory │ ├─ index index application runtime directory │ └─ admin admin application runtime directory

Such a look at the multiple applications of ThinkPHP6 is no more than this, a foreground index application, a background admin application, which is called multi-application. Back then, we used ThinkPHP5 to develop foreground application index and background application admin. What's the difference?

Difference 1: it must be downloaded through composer before it can be used.

The ThinkPHP6 framework is downloaded as a single application by default. If you want to use multiple applications, you need to download:

Composer require topthink/think-multi-app

Difference 2: the routing definition must be under the current application.

When we know ThinkPHP5, we can define the route file in the root directory, but after ThinkPHP6, we must define the route in the application directory.

Distinguish between 3:ThinkPHP6 support application portals.

We can set the entry file separately for an application in ThinkPHP6, such as the admin application. I can set the admin.php entry file to access it.

Difference 4: domain name binding application.

For example, when ThinkPHP5, we define www.a.com/index/index... After routing, you can achieve such an effect www.a.com/company.htm.

But ThinkPHP6 you will find that how to set up routing, index applications can not be removed, it is always www.a.com/index/compa … Hey, what can I do with this?

Then the domain name binding application can be used in the solution. We define the domain name and application binding in the config/app.php configuration file as follows:

'domain_bind' = > [' www.a.com' = > 'index', / / Domain binding to www App' admin.a.com' = > 'admin', / / admin binding to backend App]

So we can use www.a.com/company.htm... To visit.

This is the end of the content of "what is the difference between the multi-application of TP6 and TP5". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report