windows安装网站开发框架thinkphp8

生活日记 工作心得
11
发表时间: 编辑:顾永胜来源:0513.city标签:网站开发

一、前置准备:安装 Composer

ThinkPHP8 必须依赖 Composer 进行安装、依赖管理与版本更新。

Composer 下载地址:https://getcomposer.org/Composer-Setup.exe

安装说明:下载后双击安装包默认安装,程序会自动识别本地 PHP 环境,安装完成后重启命令行窗口,保证 Composer 命令全局生效。

二、安装 ThinkPHP8 框架

打开文件夹,进入项目安装目录,地址栏输入 cmd 回车,打开命令行

复制以下命令,创建名为 citya 的 ThinkPHP8 项目(项目名可自定义)
composer create-project topthink/think citya

三、安装报错解决方案

报错提示:Root composer.json requires topthink/think-trace ^2.0, found topthink/think-trace[2.0.x-dev] but it does not match your minimum-stability.

解决方法:复制执行下方命令,清除仓库配置后重新安装项目即可

composer config -g --unset repos.packagist

四、ThinkPHP8 框架更新命令

cmd 进入 citya 项目根目录,执行命令更新框架至最新版本

composer update

五、安装常用开发扩展(按需复制执行)

多应用模式扩展

composer require topthink/think-multi-app

视图模板驱动

composer require topthink/think-view

图片验证码扩展

composer require topthink/think-captcha

系统助手函数库

composer require topthink/think-helper

六、本地项目启动与访问

cmd 进入 citya 项目根目录,启动本地开发服务

php think run

项目访问地址:http://localhost:8000/

自定义端口启动(示例为80端口,可自行修改)
php think run -p 80

关闭本地服务:命令行按下 Ctrl+C

七、补充说明

全新安装的 ThinkPHP8 默认是单应用模式,适合小型项目;如需开发多模块项目,可自行调整目录结构,开启多应用开发模式。