簡體   English   中英

為什么我不能使用Composer將Guzzle導入我的Laravel項目?

[英]Why I can't import Guzzle into my Laravel project using Composer?

我是PHPLaravel的新手 ,嘗試添加Guzzle庫時遇到了一些困難(我可以用PHP slang稱它為庫,我來自Java嗎?)。

所以我遵循了這篇SO帖子的建議: Laravel 5中的Installation Guzzle

我已將此依賴項添加到我的composer.json文件中:“ guzzle / guzzle”:“ *”

我已將其添加到原始文件的這一部分(由Laravel生成):

"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.0",
    "symfony/css-selector": "3.1.*",
    "symfony/dom-crawler": "3.1.*",
    "guzzle/guzzle":"*"
},

我不知道這是正確的位置。

然后,我在外殼中執行了composer update語句(從項目的根目錄),並獲得以下輸出:

Andrea@Andrea-PC MINGW64 ~/Documents/Betrivius/WorkSpace/betriviusExtranet (master)
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.

我沒有看到任何錯誤,因此我認為它已成功完成。

問題是我無法在項目中找到這些依賴關系,而在使用類definitio之前,我嘗試使用它:

use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;

我收到此錯誤消息:

Undefine namespace
Referenced namespace is not found

具體來說,我在這4個紅色名稱空間上獲得一條錯誤消息:

在此處輸入圖片說明

為什么? 怎么了? 我想念什么? 如何解決此問題?

如前所述,你應該使用guzzlehttp/guzzle ,而不是guzzle/guzzle

如果您確實需要使用guzzle/guzzle ,則可以通過Guzzle命名空間而不是為新版本保留的GuzzleHttp導入它。

食欲/食欲被遺棄,您應該避免使用它。 使用guzzlehttp / guzzle代替

使用guzzlehttp / guzzle

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM