0

我在vlucas/phpdotenv安装时遇到问题

 ~/ nslookup repo.packagist.org
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   repo.packagist.org
Address: 54.37.2.184

我的composer.json

{
    "name": "developer/mvc",
    "authors": [
        {
            "name": "Abubakr Abduvakhidov",
            "email": "abubakr@edu.thedevs.co"
        }
    ],
    "autoload": {
        "psr-4": {
            "app\\": "."
        }
    },
    "require": {}
}

输出composer diagnose

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.0.8
PHP version: 7.4.12
PHP binary path: /usr/local/Cellar/php/7.4.12/bin/php
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020
cURL version: 7.73.0 libz 1.2.11 ssl OpenSSL/1.1.1h
zip: extension present, unzip present

当我运行这个命令时:

composer require vlucas/phpdotenv -vvv

我得到以下输出:

Loading config file /Users/abubakr/.composer/config.json
Loading config file /Users/abubakr/.composer/auth.json
Failed to initialize global composer: Composer could not find the config file: /Users/abubakr/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 2.0.8 (2020-12-03 17:20:38) with PHP 7.4.12 on Darwin / 20.1.0
Loading config file /Users/abubakr/.composer/config.json
Loading config file /Users/abubakr/.composer/auth.json
Failed to initialize global composer: Composer could not find the config file: /Users/abubakr/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading ./composer.json
Loading config file /Users/abubakr/.composer/config.json
Loading config file /Users/abubakr/.composer/auth.json
Loading config file ./composer.json
Checked CA file /usr/local/etc/openssl@1.1/cert.pem: valid
Executing command (/Users/abubakr): git branch -a --no-color --no-abbrev -v
Executing command (/Users/abubakr): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/Users/abubakr): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/Users/abubakr): hg branch
Executing command (/Users/abubakr): fossil branch list
Executing command (/Users/abubakr): fossil tag list
Executing command (/Users/abubakr): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /Users/abubakr/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Downloading https://packagist.phpcomposer.com/packages.json
[200] https://packagist.phpcomposer.com/packages.json
Writing /Users/abubakr/.composer/cache/repo/https---packagist.phpcomposer.com/packages.json into cache
Downloading https://packagist.phpcomposer.com/p2/vlucas/phpdotenv.json
[404] https://packagist.phpcomposer.com/p2/vlucas/phpdotenv.json
Downloading https://packagist.phpcomposer.com/p2/vlucas/phpdotenv~dev.json
[404] https://packagist.phpcomposer.com/p2/vlucas/phpdotenv~dev.json
Downloading https://packagist.org/search.json?q=vlucas/phpdotenv&type=
[200] https://packagist.org/search.json?q=vlucas/phpdotenv&type=

                                                                               
  [RuntimeException]                                                           
  No composer.json present in the current directory, this may be the cause of  
   the following exception.                                                    
                                                                               

Exception trace:
 () at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Command/RequireCommand.php:193
 Composer\Command\RequireCommand->execute() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Console/Application.php:310
 Composer\Console\Application->doRun() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Console/Application.php:122
 Composer\Console\Application->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/bin/composer:63
 require() at /usr/local/Cellar/composer/2.0.6/bin/composer:24

                                            
  [InvalidArgumentException]                
  Could not find package vlucas/phpdotenv.  
                                            
  Did you mean one of these?                
      vlucas/phpdotenv                      
      sobyte/dotenv-php                     
      calgamo/module-php-dotenv             
      abacaphiliac/zend-phpdotenv           
      davek1312/config                      
                                            

Exception trace:
 () at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Command/InitCommand.php:796
 Composer\Command\InitCommand->findBestVersionAndNameForPackage() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Command/InitCommand.php:430
 Composer\Command\InitCommand->determineRequirements() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Command/RequireCommand.php:189
 Composer\Command\RequireCommand->execute() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Console/Application.php:310
 Composer\Console\Application->doRun() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/src/Composer/Console/Application.php:122
 Composer\Console\Application->run() at phar:///usr/local/Cellar/composer/2.0.6/bin/composer/bin/composer:63
 require() at /usr/local/Cellar/composer/2.0.6/bin/composer:24

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

我预计会发生这种情况:要安装的包

额外的:

 /Applications/XAMPP/xamppfiles/htdocs/php/mvc/ [master+*] which composer
/usr/local/bin/composer
 /Applications/XAMPP/xamppfiles/htdocs/php/mvc/ [master+*] alias | grep composer

 /Applications/XAMPP/xamppfiles/htdocs/php/mvc/ [master+*] ls
composer.json  core           models         vendor
composer.lock  migrations     public         views
controllers    migrations.php runtime
4

1 回答 1

0

实际上,这是因为从https://packagist.phpcomposer.com/packages.json加载元数据,这不是官方的 Packagist,而是官方镜像(根据https://github.com 中的列表,它是一个损坏的镜像。 com/Webysther/packagist-mirror#-packagist-public-metadata-mirrors-observatory-around-the-world

这可能是问题的原因:在此存储库的元数据中找不到包,但存储库仍然公开官方搜索端点而不是镜像端点,作曲家在查找替代名称时会使用该端点。

在底部运行命令后,它开始下载

composer config -g repo.packagist composer https://packagist.org
于 2020-12-16T11:53:30.613 回答