我有一个正在运行的项目,有一些依赖项。我正在做一些修改,并且需要一个新的包。因此,在我的开发平台上,我运行
composer require x/x
并且安装了该软件包。
现在我正在将其推向产品。因此,我已经安装了
vendor/
文件夹,其中安装了所有依赖项,但我还没有新包及其内容。我知道如果我运行 composer install
,我将安装新软件包而不是其他任何东西,但是有没有办法知道(命令)实际上有一个新软件包要安装?
出现这个问题是因为我不想每次在 CI/CD 中都运行
composer install
,而只在需要时才运行。有办法吗?
否则,我想我必须检查
composer.json
/composer.lock
上的文件修改。
composer diagnose
的输出:
root@34ac8973c327:/app# composer diagnose
Checking composer.json: OK
Checking composer.lock: OK
Checking platform settings: OK
Checking git settings: OK git version 2.39.5
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking Composer version: OK
Checking Composer and its dependencies for vulnerabilities: OK
Composer version: 2.8.3
PHP version: 8.3.14
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 3.0.15 3 Sep 2024
curl version: 7.88.1 libz 1.2.13 ssl OpenSSL/3.0.15
zip: extension present, unzip present, 7-Zip not available
我已经尝试过
composer status
但它只显示您是否修改了 vendor/
中的文件(检查软件包的完整性),而不显示所有软件包是否正确安装了 composer.json
/ composer.lock
。
发布这个问题后我一直在寻找,我想我得到了答案。
我查看了运行日志
composer install
,看起来像这样(当没有什么可做的时候):
root@f431aaa99341:/app# composer install --dry-run -vvv
Running 2.8.3 (2024-11-17 13:13:04) with PHP 8.3.14 on Linux / 5.15.153.1-microsoft-standard-WSL2
Reading ./composer.json (/app/composer.json)
Loading config file ./composer.json (/app/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/app): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing async command (/app): 'git' 'rev-list' 'main..7-api-user'
Executing async command (/app): 'git' 'rev-list' 'remotes/origin/main..7-api-user'
Failed to initialize global composer: Composer could not find the config file: /config/composer/composer.json
Reading /app/vendor/composer/installed.json
Loading plugin Symfony\Component\Runtime\Internal\ComposerPlugin (from symfony/runtime)
Loading plugin Symfony\Flex\Flex (from symfony/flex)
Reading ./composer.lock (/app/composer.lock)
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Reading ./composer.lock (/app/composer.lock)
> pre-pool-create: Symfony\Flex\Flex->truncatePackages
Reading /root/.cache/composer/repo/flex/symfony-recipes-flex-main-index.json from cache
Reading /root/.cache/composer/repo/flex/symfony-recipes-contrib-flex-main-index.json from cache
Downloading https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json
Downloading https://raw.githubusercontent.com/symfony/recipes-contrib/flex/main/index.json
> pre-pool-create: Symfony\Flex\Flex->truncatePackages
Reading /root/.cache/composer/repo/flex/symfony-recipes-flex-main-index.json from cache
Reading /root/.cache/composer/repo/flex/symfony-recipes-contrib-flex-main-index.json from cache
Downloading https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json
Downloading https://raw.githubusercontent.com/symfony/recipes-contrib/flex/main/index.json
[304] https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json
[304] https://raw.githubusercontent.com/symfony/recipes-contrib/flex/main/index.json
Built pool.
Generating rules
Resolving dependencies through SAT
Looking at all rules.
Dependency resolution completed in 0.001 seconds
> pre-operations-exec: Symfony\Flex\Flex->recordOperations
Nothing to install, update or remove
93 packages you are using are looking for funding.
> pre-operations-exec: Symfony\Flex\Flex->recordOperations
Nothing to install, update or remove
93 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
然后我在 Github 上查看了 Composer 源代码,简单阅读后发现,我们运行
composer install
时所做的“差异”(为了只安装需要的包)是代码,但没有关联的直接命令。
通过快速阅读,它可以通过 installed.json
文件满足您的作曲家需求。
最后,我相信目前还没有任何composer命令能够满足我的具体需求。