Yurunsoft / Guzzle-Swoole

让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
MIT License
161 stars 21 forks source link

重复定义方法了,怎么解决 #4

Closed aogg closed 5 years ago

aogg commented 5 years ago

Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump PHP Fatal error: Cannot redeclare GuzzleHttp\uri_template() (previously declared in /www/n8n8/SmartCloud/vendor/guzzlehttp/guzzle/src/functions.php:17) in /www/n8n8/SmartCloud/vendor/yurunsoft/guzzle-swoole/src/load.php on line 31

Fatal error: Cannot redeclare GuzzleHttp\uri_template() (previously declared in /www/n8n8/SmartCloud/vendor/guzzlehttp/guzzle/src/functions.php:17) in /www/n8n8/SmartCloud/vendor/yurunsoft/guzzle-swoole/src/load.php on line 31

aogg commented 5 years ago

你现有composer的内容 "extra": { "class": "Yurun\Util\Swoole\Guzzle\Plugin\Plugin", "include_files": [ "src/load.php", "src/functions.php" ] },

但现有github目录中却没有load这个文件,这是为什么

Yurunsoft commented 5 years ago

load.php是通过读取源代码,修改后,写入的

你是执行了什么命令出现的这个问题?

aogg commented 5 years ago

composer require

composer配置为: "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ]

Yurunsoft commented 5 years ago

composer.json中还需要手动进行引用guzzle

{
    "require": {
        "guzzlehttp/guzzle": "~6.0",
        "yurunsoft/guzzle-swoole": "^1.1"
    }
}

你试一下

marscoo commented 5 years ago

@aogg @Yurunsoft

測試後發現當composer.jsonpost-autoload-dump含有 Illuminate\\Foundation\\ComposerScripts::postAutoloadDump便會報錯

post-autoload-dump改為以下寫法便可:

"post-autoload-dump": [
  "rm -f bootstrap/cache/services.php",
  "rm -f bootstrap/cache/packages.php",
  "@php artisan package:discover"
]

效果與Laravel 5.7的Illuminate\\Foundation\\ComposerScripts::postAutoloadDump一致,雖然這樣修改是比較不優雅,但希望能幫到你們