FastAdmin 优化主框架依赖加载

Fastadmin 现在还在坚持使用 ThinkPHP5.0,并自行 fork 进行了维护,如果我们打开 composer.json 就可以看见里面会被指向到 gitee 由 fastadmin 维护的库。

1
2
3
4
5
6
"repositories": [
{
"type": "git",
"url": "https://gitee.com/fastadminnet/framework.git"
}
]

如果我们清除了 composer 缓存,然后进行 composer install -vvv 安装依赖,会发现把这个 git 源的数据都拉下来了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Executing command (CWD): git clone --mirror -- 'https://gitee.com/fastadminnet/framework.git' '/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/'
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git show-ref --tags --dereference
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git branch --no-color --no-abbrev -v
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git remote -v
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git remote set-url origin -- 'https://gitee.com/fastadminnet/framework.git' && git remote show origin && git remote set-url origin -- 'https://gitee.com/fastadminnet/framework.git'
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git show 'master':'composer.json'
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git -c log.showSignature=false log -1 --format=%at 'master'
Reading composer.json of topthink/framework (v5.0.0)
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git show '4115408538b566d795d621385f9c293f026fb3f4':'composer.json'
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git -c log.showSignature=false log -1 --format=%at '4115408538b566d795d621385f9c293f026fb3f4'
Writing /tmp/cache/repo/https---gitee.com-fastadminnet-framework.git/4115408538b566d795d621385f9c293f026fb3f4 into cache
Importing tag v5.0.0 (5.0.0.0)
Reading composer.json of topthink/framework (v5.0.1)
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git show '0e39004f5661ad6c11e1b00026aa9d857068dbbc':'composer.json'
Executing command (/tmp/cache/vcs/https---gitee.com-fastadminnet-framework.git/): git -c log.showSignature=false log -1 --format=%at '0e39004f5661ad6c11e1b00026aa9d857068dbbc'
Writing /tmp/cache/repo/https---gitee.com-fastadminnet-framework.git/0e39004f5661ad6c11e1b00026aa9d857068dbbc into cache

如何我们再做个测试,清空缓存和项目下的 vendor 文件夹,再执行 composer install -vvv ,会发现因为 lock 文件的存在,这次就不会拉取全部了。

挺害怕 gitee 如果再有审查,限制了 git clone 匿名拉取,且那会刚刚好业务紧急呢?

目前在 GitHub 弄了个同步的,接下来就要想如何在 composer.json 中引入了。

注意,你不应该对包进行重命名,除非你真的打算摆脱原来的包,并长期的使用你自己的 fork。

之前我想过 fork 然后重命名仓库名称(framework 会有其他重复),但官方不建议这样子做。

目前找到的方法,我们可以通过 type=package 的方式来进行引入。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"repositories": [
{
"type": "package",
"package": {
"name": "topthink/framework",
"version": "dev-master",
"type": "think-framework",
"dist": {
// https://github.com/hongfs/hongfs/archive/096811899433eb0eb0988f1fe1db56ebb521bf34.zip
"url": "https://hk.hongfs.dev/composer/repos/hongfs/hongfs/zipball/096811899433eb0eb0988f1fe1db56ebb521bf34",
"type": "zip"
}
}
}
]

这种相当于直接把版本写死了,也能很好的做版本管理处理。

随着 PHP 7.4 结束最后的安全周期,也期待 Fastadmin 可以尽快适配 8。

往上