Home > Article > PHP Framework > ThinkPHP6.0 turns on multi-application mode
ThinkPHP has developed to the 6..0. Optimization improvements and more standardization. Due to the introduction of some new features, the ThinkPHP6.0 operating environment requires PHP7.1 and does not support seamless upgrades to 5.1 (the official upgrade guide is provided for project upgrade reference). From version 6 onwards, the official website will no longer provide downloads. Composer is required to install or update, and Git download and installation is not allowed.
1. Install the thinkphp6.0 framework:
composer create-project topthink/think thinkphpV6.0.5
Generate the directory. The default directory structure after installation is a single application mode. :
#2. When the framework needs to use multiple application modules, it cannot directly create a module like tp5. Composer needs to install the corresponding think The -multi-app extension can only be used.
Install multi-application module extension: think-multi-app:
composer require topthink/think-multi-app
Special note: When installing, it must be installed in the root directory of the project, otherwise it will be used after installation. No, then there is a problem with the order application (app\controller\index does not exist).
3. Delete the controller directory under the app directory, and then execute the following instructions to generate the index module:
Instruction code:
php think build index //其中index是要生成的模块 //如果要生成admin模块,则将index改成admin。
After execution, check the project directory in phpstorm and you can generate the index module.
Note:
The three files BaseController.php, Request.php and ExceptionHandle.php are the basic files provided by the system by default. You can move them at will. , but be careful to adjust the namespace of the class synchronously. If you do not need to use the Request.php and ExceptionHandle.php files, or if you want to adjust the class name, remember to adjust the container object binding in the provider.php file simultaneously.
4. Download and install think-view template engine driver extension:
composer require topthink/think-view
5. Multi-mode access is enough .
Enter in the browser: http://localhost:8010/thinkPHPV6.0.5/public/ (note the port number, mine is 8010), observe Effect:
If it appears: No input file specified.
The solution is:
Open the .htaccess file under public,
Put:RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
Change to:RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
The above is the detailed content of ThinkPHP6.0 turns on multi-application mode. For more information, please follow other related articles on the PHP Chinese website!