Article directory
ThinkPHP6 installation
6.0
Starting from the version, it mustComposer
be installed and updated through the method, so you cannotGit
download and install it.PHP >= 7.2.5
1. Install Composer
- install on windows
installation steps
The first step: use cmd to enter the php directory, if it is a small skin panel, it is D:\phpstudy_pro\Extensions\php\php7.4.3nts
Step 2: Execute the command, php -r "copy('https://install.phpcomposer.com/installer',
'composer-setup.php');"Step 3: Execute the command, php composer-setup.php
Step 4: Execute the command, php -r "unlink('composer-setup.php');"
Step 5: Add path environment variable, the parameter is composer path
Step 6: Enter the php file directory, create a new file: composer.bat file, copy the command @php "%~dp0composer.phar" %*
into it, then save it, and enter the command composer --version to check the composer version
- Install on macbook, download Composer software
installation steps
Step 1: Terminal command, copy the file to the specified directory
mv composer.phar /usr/local/bin/composer
Step 2: Install a plugin
composer require
phpoffice/phpspreadsheet/Applications/MAMP/bin/php/php7.4.3/bin
2. Set Composer download source
- First set the download source of Composer, which is also the mirror address
In the command line window or console enter
composer config -g repo.packagist composer https://packagist.phpcomposer.com
- Foreign websites are slow, and the official website recommends using domestic mirrors (Alibaba Cloud)
Aliyun mirror
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer
3. Composer download and install ThinkPHP6
- First switch to the root directory of the php environment
cd d:/phpstudy/www
- Execute the download Thinkphp6 command. The last tp is to create a new tp directory, which can be renamed
composer create-project topthink/think tp
- To update the Thinkphp6 core, you must first switch to the tp root directory
update topthink/framework
- Note: The directory where the installation and update commands are located is different, and the update must be executed under the root directory of your application
4. Directory structure after successful installation
- The main change in the directory structure of version 6.0 is that the core framework is included in
vendor
the directory, and then the originalapplication
directory becomesapp
a directory. - The directory structure after installation is a single application mode
- Under
mac
the orlinux
environment, note thatruntime
the directory permission needs to be set to 777
www WEB部署目录(或者子目录)
├─app 应用目录
│ ├─controller 控制器目录
│ ├─model 模型目录
│ ├─view 视图目录
│ ├─ ... 更多类库目录
│ │
│ ├─BaseController.php 默认基础控制器类
│ ├─ExceptionHandle.php 应用异常定义文件
│ ├─common.php 全局公共函数文件
│ ├─middleware.php 全局中间件定义文件
│ ├─provider.php 服务提供定义文件
│ ├─Request.php 应用请求对象
│ └─event.php 全局事件定义文件
│
├─config 配置目录
│ ├─app.php 应用配置
│ ├─cache.php 缓存配置
│ ├─console.php 控制台配置
│ ├─cookie.php Cookie配置
│ ├─database.php 数据库配置
│ ├─filesystem.php 文件磁盘配置
│ ├─lang.php 多语言配置
│ ├─log.php 日志配置
│ ├─middleware.php 中间件配置
│ ├─route.php URL和路由配置
│ ├─session.php Session配置
│ ├─trace.php Trace配置
│ └─view.php 视图配置
│
├─view 视图目录
├─route 路由定义目录
│ ├─route.php 路由定义文件
│ └─ ...
│
├─public WEB目录(对外访问目录)
│ ├─index.php 入口文件
│ ├─router.php 快速测试文件
│ └─.htaccess 用于apache的重写
│
├─extend 扩展类库目录
├─runtime 应用的运行时目录(可写,可定制)
├─vendor Composer类库目录
├─.example.env 环境变量示例文件
├─composer.json composer 定义文件
├─LICENSE.txt 授权说明文件
├─README.md README 文件
└─think 命令行入口文件
Five, run Thinkphp6
- Note: We only talk about the php environment integration package in the windows system, how to access
配置步骤
第一步:打开 phpstudy 集成软件 -》 站点域名管理
第二步:网站域名:www.xxx.com
第三步:网站目录:tp/public
第四步:在 C:\Windows\System32\drivers\etc 目录下,打开 hosts 文件
第五步:最后一行输入 127.0.0.1 www.xxx.com
第六步:直接在浏览器上输入域名(www.xxx.com)