我正在构建一个需要guzzlehttp/guzzle
软件包的自定义Laravel软件包。以下是我的composer.json文件:
{
"name": "lomse/awesomePackage",
"description": "this an awesome package",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Selom",
"email": "awesome@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"guzzlehttp/guzzle": "^6.3"
},
"autoload": {
"psr-4": {
"Lomse\\AwesomePackage\\": "src/"
}
}
}
下面是我的AwesomeProvider.php
文件的内容:
<?php
namespace Lomse\AwesomePackage;
use GuzzleHttp\Client;
use Illuminate\Support\ServiceProvider;
class AwesomeProvider extends ServiceProvider
{
public function boot(){
}
public function register()
{
$this->app->singleton(Awesome::class, function ($app) {
return new Awesome(new Client); //Class 'GuzzleHttp\Client' not found
});
}
}
我不断收到Class 'GuzzleHttp\Client' not found
。
我在做什么错了?
答案 0 :(得分:1)
因此,事实证明这很简单。我重点介绍了解决此问题要采取的步骤。希望这对遇到相同问题的所有人有所帮助。
lomse/awesome-package
然后在preferred-install
配置属性中将dist
指定为./lomse/awesome-package/package.json
:
“配置”:{ “ preferred-install”:“ dist” }
完整代码是
{
"name": "lomse/awesome-package",
"description": "this an awesome package",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Selom",
"email": "awesome@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"guzzlehttp/guzzle": "^6.3"
},
"autoload": {
"psr-4": {
"Lomse\\AwesomePackage\\": "src/"
}
},
"config": {
"preferred-install": "dist"
}
}
在根package.json
中,如下指定软件包的存储库:
"repositories": [
{
"type": "git",
"url": "git@github.com:lomse/awesome-package.git"
}
]
还将您的软件包存储库添加到package.json require
属性中,如下所示:
"lomse/awesome-package": "dev-master"
在您的根目录中,运行以下代码以更新依赖关系。这会将lomse/awesome-package
存储库克隆到您的供应商文件夹中,并安装您的软件包所需的任何其他依赖项:
composer update -vvv
-vvv
用于调试