[英]Guzzle/Nexmo Issues After Upgrading to Laravel 8
我最近對這個 web 應用程序進行了相當大的更新,並且在大多數情況下它順利進行......直到應用程序嘗試從登台/生產發送短信通知。
從 laravel 7.x 升級到 8.x 非常簡單明了。 同時我們還安裝了Laravel Horizon。 一切都按計划進行,並且在本地一切正常。
但是,當我們部署到登台/生產時,排隊的 SMS 通知會失敗,並出現以下異常:
ReflectionException: Class Http\Adapter\Guzzle6\Client 不存在於 /home/forge/dev.example.com/releases/20210609194554/vendor/laravel/framework/src/Illuminate/Container/Container.ZE1BFD762321E409CEE4ZAC0B36E841963C
查看堆棧跟蹤,我們可以看到 Nexmo 是罪魁禍首:
#5 /home/forge/dev.example.com/releases/20210609194554/vendor/nexmo/laravel/src/NexmoServiceProvider.php(150): Illuminate\Foundation\Application->make()
然而,在我們的 composer.json 文件中,我們需要 Guzzle 7 的以下內容:
"guzzlehttp/guzzle": "^7.3",
在這一點上再次值得一提的是,我在本地發送短信沒有問題,本地和暫存環境的主要區別在於,在本地我使用 Laravel Valet 而 Staging 使用 Laravel Envoyer。
到目前為止我已經嘗試過:
"guzzlehttp/guzzle": "^7.3"
更改為"guzzlehttp/guzzle": "^6.5|^7.3"
php artisan horizon:purge
和php artisan horizon:terminate
手動和部署掛鈎。php artisan queue:restart
composer dump-autoload
和composer dump-autoload -o
composer install
和更多...
任何幫助是極大的贊賞
更新如下:
完成作曲家.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.4.1",
"arrilot/laravel-widgets": "^3.13",
"barryvdh/laravel-snappy": "^0.4.6",
"doctrine/dbal": "^2.10",
"facade/ignition": "^2.3.6",
"guzzlehttp/guzzle": "^7.3",
"intervention/image": "^2.4",
"laravel/framework": "^8.0",
"laravel/helpers": "^1.3",
"laravel/horizon": "^5.7",
"laravel/nexmo-notification-channel": "^2.5.1",
"laravel/passport": "^10.0",
"laravel/slack-notification-channel": "^2.0",
"laravel/telescope": "^4.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",
"league/csv": "^8.2",
"league/flysystem-aws-s3-v3": "~1.0",
"maatwebsite/excel": "^3.1",
"milon/barcode": "^8.0.1",
"nexmo/laravel": "^2.4.1",
"nunomaduro/collision": "^5.0",
"predis/predis": "^1.1",
"pusher/pusher-php-server": "^4.1.1",
"webpatser/laravel-uuid": "^3.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "^9.0",
"filp/whoops": "~2.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
此外,我的 nexmo 配置文件沒有任何用於 http_client 的內容,也許這是我錯過的升級步驟。 因此,對於nexmo 的http_client,我的.env 文件中沒有任何內容。 我也將開始研究這個。
nexmo.php
<?php
return [
/*
|--------------------------------------------------------------------------
| API Credentials
|--------------------------------------------------------------------------
|
| If you're using API credentials, change these settings. Get your
| credentials from https://dashboard.nexmo.com | 'Settings'.
|
*/
'api_key' => function_exists('env') ? env('NEXMO_KEY', '') : '',
'api_secret' => function_exists('env') ? env('NEXMO_SECRET', '') : '',
/*
|--------------------------------------------------------------------------
| Signature Secret
|--------------------------------------------------------------------------
|
| If you're using a signature secret, use this section. This can be used
| without an `api_secret` for some APIs, as well as with an `api_secret`
| for all APIs.
|
*/
'signature_secret' => function_exists('env') ? env('NEXMO_SIGNATURE_SECRET', '') : '',
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| Private keys are used to generate JWTs for authentication. Generation is
| handled by the library. JWTs are required for newer APIs, such as voice
| and media
|
*/
'private_key' => function_exists('env') ? env('NEXMO_PRIVATE_KEY', '') : '',
'application_id' => function_exists('env') ? env('NEXMO_APPLICATION_ID', '') : '',
/*
|----------------------------------------------------------------------------
| Phone Numbers
|----------------------------------------------------------------------------
|
| Phone numbers to be used by the application.
*/
'number' => env('NEXMO_NUMBER'),
'batch' => env('NEXMO_BATCH'),
];
我看到NexmoServiceProvider
正在嘗試使用配置中定義的http_client
,所以你能分享一下.env
對NEXMO_HTTP_CLIENT
有什么嗎? 我很確定你那里有問題,甚至沒有定義。
這就是在與該配置相關的config/nexmo.php
中定義的內容:
'http_client' => function_exists('env') ? env('NEXMO_HTTP_CLIENT', '') : '',
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.