Composer 安装 ThinkPHP6 问题
2022-11-24 11:10:29
186
{{single.collect_count}}

Composer 安装 ThinkPHP6 问题


参考:
ThinkPHP6.0完全开发手册

先说说问题


执行ThinkPHP6的安装命令

composer create-project topthink/think tp

遇到问题汇总如下:

composer create-project topthink/think tpWarning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2

在这里插入图片描述


看提示是要更新版本,执行命令更新。

composer self-update

更新之后,再次安装ThinkPHP,之后遇到如下问题。

> @php think service:discover[Error]Class 'think\Paginator' not found > @php think vendor:publish[Error]Class 'think\Paginator' not found

在这里插入图片描述


尝试了很多方法,依然不能解决。其中包括使用https://packagist.phpcomposer.com的镜像。
这时候遇到问题如下,

[InvalidArgumentException]Could not find package topthink/think with stability stable.

在这里插入图片描述


最后解决方式为,更换了阿里云的镜像!所以归根结底还是因为…被墙了吧!(虽然翻墙了,但是也没行……)
好了,正确的方式如下:

一.运行环境要求

运行环境要求PHP7.1+
Composer 2.0+
阿里的源 https://mirrors.aliyun.com/composer/

二.配置

一、查看Composer 本身的源

composer config -g -l

在这里插入图片描述
二、更改为阿里的源

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

在这里插入图片描述
三、最后执行ThinkPHP6的下载操作
如图所示,搞定!艾玛~
在这里插入图片描述
最后补充一下解除镜象指令:

composer config -g --unset repos.packagist

执行之后,composer 会利用默认值(也就是官方源)重置源地址。


让人亲切的页面
在这里插入图片描述

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}