ThinkPHP Learning Notes (I) ThinkPHP Deployment

  • 2021-07-02 23:43:50
  • OfStack

wampserver has been downloaded, and you will have time to try running ThinkPHP locally in the future.

Under the app/lib/Action/ folder, you can define a controller class for each module, and a module can contain multiple operation methods. When there is a request, the currently requested module and operation will be parsed from the URL parameters. For example, the default controller class IndexAciton. class. php is defined:


<?php
class IndexAction extends Action{
  ptotect function _initialize(){
    header("Content-Type:text/html;charset=utf-8");
  }
  public function index(){
    $this->display();
  }
  public function imit(){
    echo "<h2>Sae Service Simulator Functional Testing ( The following services can also run locally ) : </h2>";
  }
}

By accessing http://localhost/, the system accesses the default action (index) of the default module (Index). With the relative input http://localhost/Index/imit, the system accesses the operation method (imit) of the default module (Index). This URL mode is the default format of PATHINFO mode and ThinkPHP, and other formats can be set in ThinkPHP/Conf/convention. php, such as normal mode, REWRITE mode and compatible mode.

It's just notes, why can't you set it to be visible only to yourself? I'm embarrassed to show people my messy 78.

The REWRITE mode requested by URL is the support for adding rewriting rules on the basis of PATHINFO mode. If Apache is used, it is to add. htaccess file at the same level of entry file, and the content is:


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

This is the only way to do it. You need to turn on the rewrite function of Apache. In the httpd. conf configuration file, find LoadModule rewrite_module modules/mod_rewrite. so remove the preceding #, find AllowOverride None and change to AllowOverride All. That's how it works.


Related articles: