无法使用Composer安装log4php

时间:2018-11-21 20:23:43

标签: php composer-php log4php

我正在尝试在ubuntu服务器上部署PHP webapp。 运行composer安装会因以下异常而结束:

  [RuntimeException]                                                                                                                                                                                                    
  Failed to execute git clone --no-checkout 'https://git-wip- 
  us.apache.org/repos/asf/logging-log4php.git' 
  '/var/www/webapp/public_html/vendor/apache/log4php' && cd 
  '/var/www/webapp/public_html/vendor/apache/log4php' && git remote 
  add composer 'https://git-wip-us.apache.org/repos/asf/logging-log4php.git' && git fetch composer                                                                            

  Cloning into '/var/www/webapp/public_html/vendor/apache/log4php'...                                                                                                                                      
  fatal: repository 'https://git-wip-us.apache.org/repos/asf/logging-log4php.git/' not found  

我尝试将显式存储库添加到composer.json,如下所示,但仍未取得任何进展

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/apache/logging-log4php"
  }
],
"require": {
  "apache/log4php": "2.3.0",
  "phpmailer/phpmailer": "~6.0"
}

我想念什么?

2 个答案:

答案 0 :(得分:3)

They've just migrated

更正到存储库的链接后,请不要忘记重新创建composer.lock文件。可能最简单的方法是删除它并运行composer install

答案 1 :(得分:0)

创建具有以下内容的composer.json文件:

{
    "require": {
        "apache/log4php": "^2.3.0"
    }
}

运行Composer安装过程:

php composer.phar install

这会将Apache log4php安装在vendor / apache / log4php中。

要使用log4php,只需在脚本中包含vendor / autoload.php。

require 'vendor/autoload.php';
$log = Logger::getLogger("default");
$log->info("Hello !!");