1)学习环境:
运行环境:phpstudy
PHP版本大于7.1.0
用PHPstudy启动composer下载安装
2)基础dos命令
进入某个目录:cd 目录名
退回上级目录:cd ..
3)下载安装
安装的目录必须是空文件夹
默认安装最新稳定版:composer create-project topthink/think www.blog.com(自定义安装目录)
thinkPHP所有的版本:https://packagist.org/packages/topthink/think
安装指定版本:composer create-project topthink/think=6.0.x-dev tp
4) 开启debug模式

5)访问首页
http://www.blog.com/public/index.php
安装版本ThinkPHP V6.0.5
6)url中去掉public目录
http://www.blog.com/public/index.php //调整前 http://www.blog.com/index.php //调整下
方法1:绑定域名的时候直接绑定到public目录下
方法2:移动入口文件
第1步:把public目录下:index.php .htaccess nginx.htaccess favicon.ico robots.txt router.php 六个文件移动到根目录下 第2步:修改index.php的文件引入路径: require __DIR__ . '/../vendor/autoload.php'; //原路径 require __DIR__ . './vendor/autoload.php'; //现路径
7 )开启多应用
1 composer下载多应用拓展
composer require topthink/think-multi-app//下载多应用
2 下载后的目录地址
G:\phpstudy_pro\WWW\www.blog.com\vendor\topthink\think-multi-app
3 多应用模式部署后,记得删除app
目录下的controller
目录(系统根据该目录作为判断是否单应用的依据)。
4 访问前台:http://www.blog.com/index.php/index/index/index
访问后台:http://www.blog.com/index.php/admin/index/index

8)隐藏 index.php
phpstudy配置一个网站后,会在nginx 和 apache下各配置一个 .conf文件
nginx下隐藏index.conf
server {
listen 80;
server_name www.blog.com;
root "G:/phpstudy_pro/WWW/www.blog.com/public";
location / {
index index.php index.html error/index.html;
error_page 400 /error/400.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 /error/500.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
error_page 506 /error/506.html;
error_page 507 /error/507.html;
error_page 509 /error/509.html;
error_page 510 /error/510.html;
include G:/phpstudy_pro/WWW/www.blog.com/public/nginx.htaccess;
autoindex off;
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=/$1 last;
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
Apache下 .conf
<VirtualHost *:80> DocumentRoot "G:/phpstudy_pro/WWW/www.blog.com/public" ServerName www.blog.com ServerAlias FcgidInitialEnv PHPRC "G:/phpstudy_pro/Extensions/php/php7.3.4nts" AddHandler fcgid-script .php FcgidWrapper "G:/phpstudy_pro/Extensions/php/php7.3.4nts/php-cgi.exe" .php <Directory "G:/phpstudy_pro/WWW/www.blog.com/public"> Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted DirectoryIndex index.php index.html error/index.html </Directory> ErrorDocument 400 /error/400.html ErrorDocument 403 /error/403.html ErrorDocument 404 /error/404.html ErrorDocument 500 /error/500.html ErrorDocument 501 /error/501.html ErrorDocument 502 /error/502.html ErrorDocument 503 /error/503.html ErrorDocument 504 /error/504.html ErrorDocument 505 /error/505.html ErrorDocument 506 /error/506.html ErrorDocument 507 /error/507.html ErrorDocument 510 /error/510.html </VirtualHost>
9)目录结构
www WEB部署目录(或者子目录) ├─app 应用目录 │ ├─controller 控制器目录 │ ├─model 模型目录 │ ├─ ... 更多类库目录 │ │ │ ├─common.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 命令行入口文件