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

How to solve the pit installed by thinkphp6

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to solve the pit of thinkphp6 installation". The editor shows you the operation process through the actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to solve the pit of thinkphp6 installation" can help you solve the problem.

Tai Hang =

For the phpstudy website, disable open_dir to prevent cross-site attacks, otherwise you will not be able to access the outside after setting the public directory as the root directory of the site.

If you set it in php_ini, turn it off or set the normal directory.

This setting may also be available in nginx and fastcgi.conf.

Display_errors = On

Display_startup_errors = On

It is not enabled by default.

This error can be reported even if the frame is not open, which may be due to the setting of iniset, but the frame will not be effective until it is started normally. Otherwise, for example, if the 500 error framework is not started at all, it will not be able to report an error.

In addition, if it is a copy of the file permissions may also be set to 755

Then the runtime directory is set to 777

Basic error display

Except for the big pit above, env is generally set.

Configure [DATABASE] USERNAME = rootPASSWORD = 123456use think\ facade\ Envfunction () {/ / get the environment variable if it does not exist, use the default value rootEnv::get ('database.username',' root');} controller two special controllers

I. basic controller

In general, after creating a controller, it is recommended to inherit the underlying controller to get more methods

The base controller only provides controller verification and injects think\ App and think\ Request

These two objects will be explained in detail in later chapters. Let's inherit and simply use them.

Namespace app\ controller; use app\ BaseController; class Test extends BaseController {public function index () {/ / return the actual path return $this- > app- > getBasePath (); / / return the current method name return $this- > request- > action ();}}

In single application mode, we can define an Error controller class for the project to remind us of errors

Class Error {public function index () {return 'current controller does not exist!' ;} model

The meaning of Vernier

Validator use

For example, in TP3, it might be judged like this:

$name = I ('name','); if (empty ($name)) {/ / throw exception}

If there are more parameters, the more variables you need to judge, the more code will increase.

Go directly to the code:

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