多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
Thinkphp5.1版本开始,官网不再提供下载版本,需要使用 `Composer` 或者 `git` 方式安装和更新。 下面就详细讲解一下在 `Windows` 操作系统中用 `Composer` 安装的流程: >[danger] ThinkPHP5.1的环境要求如下: ~~~ PHP >= 5.6.0 PDO PHP Extension MBstring PHP Extension ~~~ ### 安装前准备 >[success] 在 Windows 中,你需要下载并运行 [Composer-Setup.exe](https://getcomposer.org/Composer-Setup.exe)。 > 如果遇到任何问题或者想更深入地学习 Composer,请参考 [Composer 中文](https://www.kancloud.cn/thinkphp/composer)。 [安装 Composer-Setup.exe 软件教程 请点击这里](https://www.kancloud.cn/yjf-kj/v2018/743788) >[success] 安装 Composer 完成后,再继续下面的操作。 > 打开CMD命令行窗口 ( 按住win键+R键 然后输入 cmd 再按回车键即可 ) > 比如将Thinkphp5.1安装到 F 盘下的Thinkphp,在命令行窗口输入 > 需要先切换到F盘,看图操作吧.~\_~ ![](https://box.kancloud.cn/3bdc00bbae3c3cb9ce94022ee7535790_527x191.png) 现在你的CMD命令行窗口界面应该是这样的:如上图所示 ~~~ F:\Thinkphp> ~~~ 第一步:选择镜像 ~~~ composer config -g repo.packagist composer https://packagist.laravel-china.org ~~~ >[danger] 运行后可能会出现: > No composer.json in current directory, do you want to use the one at F:\\Thinkphp? \[Y,n\]? > 只需要输入 Y 即可.**(不出现不用管,继续下面的操作)** 第二步:开始安装 (如果你是第一次安装的话) ~~~ composer create-project topthink/think tp5 ~~~ 上面的 `tp5` 目录名你可以任意更改,执行完毕后,会在当前Thinkphp目录下的tp5子目录安装最新版本的ThinkPHP,这个目录就是我们后面会经常提到的应用根目录。 >[success] 当你看到这个图所示证明安装成功了. 打开你的电脑F盘看看, 是不是很激动咧... ![](https://box.kancloud.cn/0a93193538f33ff87122d9279d6f5b94_609x383.png) ### 安装完成 ~\_~! >[info] 温馨提示: > 如果你之前已经安装过,那么切换到你的应用根目录下面,然后执行下面的命令进行更新: ~~~ composer update topthink/framework ~~~ ***** ***** 你可能需要安装的扩展,先进入到 应用根目录 (就是上面说到的tp5目录) 现在你的CMD命令行窗口界面最后一行应该是这样的: ~~~ F:\Thinkphp>tp5> ~~~ >[success] 确认目录正确后,继续在命令行窗口输入以下代码安装扩展 验证码 ~~~ composer require topthink/think-captcha ~~~ 图片处理 ~~~ composer require topthink/think-image ~~~ 常用助手 ~~~ composer require topthink/think-helper ~~~ #### 安装扩展的步骤 如图所示 ![](https://box.kancloud.cn/f8802ec6318cf6629eb3ec3fbd37acc6_617x516.png) 下面的备用,需要的话,自己安装咯... 针对ThinkPHP5的扩展包 需要使用Composer安装 | 扩展名 | 地址 | | --- | --- | | 应用单元测试 | [https://github.com/top-think/think-testing.git](https://github.com/top-think/think-testing.git) | | 验证码 | [https://github.com/top-think/think-captcha.git](https://github.com/top-think/think-captcha.git) | | 队列 | [https://github.com/top-think/think-queue.git](https://github.com/top-think/think-queue.git) | | MongoDb支持 | [https://github.com/top-think/think-mongo.git](https://github.com/top-think/think-mongo.git) | | angular模板引擎 | [https://github.com/top-think/think-angular.git](https://github.com/top-think/think-angular.git) | | 助手库 | [https://github.com/top-think/think-helper.git](https://github.com/top-think/think-helper.git) | | 数据库迁移工具 | [https://github.com/top-think/think-migration.git](https://github.com/top-think/think-migration.git) |