PHP 云引擎安装依赖时 composer 无法使用本地 repository

项目目录结构如图:

composer 配置

    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        },
        "lego": {
            "type": "path",
            "url": "./lego"
        }
    },

本地能正常使用,执行 lean deploy 时遇到下面报错

[REMOTE] [ERROR] 部署失败:Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 105 installs, 0 updates, 0 removals
  - Installing doctrine/inflector (2.0.3): DownloadinDownloading (100%!)(MISSING)
  - Installing doctrine/lexer (1.2.1): DownloadinDownloading (100%!)(MISSING)
  - Installing dragonmantank/cron-expression (v2.3.1): DownloadinDownloadinDownloading (100%!)(MISSING)
  - Installing symfony/polyfill-php80 (v1.20.0): DownloadinDownloading (100%!)(MISSING)
  - Installing symfony/polyfill-mbstring (v1.20.0): Downloading (connecting...)
<ignored...>
DownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloadinDownloading (100%!)(MISSING)


  [RuntimeException]
  Source path "./lego" is not found for package wutongwan/lego


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
[INFO] Deleting temporary files
Deployment failed

clone 这个项目切到 leancloud 分支后跑 composer install 碰到报错:

PHP Fatal error:  composerRequireb344e39ec61c64d748a922f55a7b8fda(): Failed opening required '/home/ubuntu/lego-demo/vendor/composer/../wutongwan/lego/src/Lego/Utility/functions.php' (include_path='.:/usr/share/php') in /home/ubuntu/lego-demo/vendor/composer/autoload_real.php on line 69

Fatal error: composerRequireb344e39ec61c64d748a922f55a7b8fda(): Failed opening required '/home/ubuntu/lego-demo/vendor/composer/../wutongwan/lego/src/Lego/Utility/functions.php' (include_path='.:/usr/share/php') in /home/ubuntu/lego-demo/vendor/composer/autoload_real.php on line 69

您是不是没有提交相应的目录?

抱歉忘记备注了,需要初始化一下 submodule

git submodule init
git submodule update

又碰到了另一个报错:

PHP Fatal error:  Default value for parameters with a class type hint can only be NULL in /home/ubuntu/lego-demo/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php on line 89

我的 PHP 版本是 7.3.24

奇怪啊,我 clone 下来执行 composer install 是没有任何问题的,用的也是 7.3.24

另外这一行的 type hint 也没有 class 呀

function assertArrayHasKey($key, $array, string $message = ''): void

您后来这个问题解决了吗?

如果没有解决的话,可以试试把 path 类型换成 vcs.
我今天下午尝试在云引擎 PHP 示例项目中引入一个 vcs 类型的本地仓库,可以成功部署。参见 leancloud/slim-getting-started#6

使用 git 替代掉了,云引擎构建过程不是在上传的代码目录执行的吗

不是,会先复制 composer.json 和 composer.lock 去安装依赖和构建。这应该就是 path 类型的 composer 仓库装不了的问题。

pdo_sqlite 扩展这个需求我会提交内部讨论,有进展会回复您。

久等了,现在云引擎 PHP 已经默认开启 sqlite3 扩展。

感谢,我试用下