composer require package_name requested for api/v3 not api/v4 on gitlab

composer require package_name requested for api/v3 not api/v4 on gitlab

当我想要使用 composer 时,它将 return 一条错误消息:

作曲家要求 Bugloos/file-manager-bundle:1.0.6

Installation failed, reverting ./composer.json to its original content.                                                                                   
  [Composer\Downloader\TransportException]                                                          
  The "https://gitlab.com/api/v3/projects/bugloos%2Flogin%2Dbundle" file could not be downloaded (HTTP/1.1 410 Gone)                                                                                

但是如果我点击 link with v4 gitlab 将 return 正确的响应,我不知道如何告诉 gitlab 用 v4 版本响应我?

"repositories": [
{
  "type": "vcs",
  "url": "git@gitlab.com:bugloos/login-bundle.git"
},

...

"require": {
   "Bugloos/LoginBundle": "^1.0", ...

...

这个 was fixed 两年前在 Composer 中。您需要更新作曲家:

composer self-update

如果全局安装了 composer,则使用 sudo:

sudo -H composer self-update

解决方法是:

更新 composer 的版本,但是 phar 不是包管理器!

我已经通过删除并再次安装最新版本来更新作曲家版本,而且因为我通过 ubuntu 包管理器安装了作曲家,它不支持此命令:

composer self-update > only works if you installed it with phar

但是如果您没有使用 phar 安装它,您必须删除它并从 official website 重新安装它,如下所示:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"