当前位置: 首页 > 知识库问答 >
问题:

如何修复config/app.php Laravel中启动未找到错误的提供程序

柳墨一
2023-03-14

我正在设置一个新的私有composer包,它有一个名为DatapageSDKProvider的提供程序。

当我将提供程序放在providers数组的config/app.php中:“Datapage\DatapageSDK\providers\DatapageSDKProvider”并尝试输入任何url时,会引发异常:

'Datapage\DatapageSDK\提供程序\DatapageSDK提供程序'未找到

这是我laravel项目的composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "type": "project",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "ms/datapage-sdk-laravel",
                "version": "0.0.3",
                "source": {
                    "url": "url_git",
                    "type": "git",
                    "reference": "develop"
                },
                "options": {
                    "ssl": {
                        "verify_peer": "false"
                    }
                }
            }
        }
    ],
    "require": {
        "php": "^7.1.3",
        "artesaos/defender": "~0.8.0",
        "aws/aws-sdk-php-laravel": "~3.0",
        "darkaonline/l5-swagger": "5.7.*",
        "doctrine/dbal": "^2.8",
        "fideloper/proxy": "^4.0",
        "laravel-notification-channels/onesignal": "^1.2",
        "laravel/framework": "5.7.*",
        "laravel/passport": "^7.0",
        "laravel/tinker": "^1.0",
        "laravellegends/pt-br-validator": "^5.1",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/fractal": "^0.17.0",
        "ms/datapage-sdk-laravel": "0.0.*",
        "prettus/l5-repository": "2.6.*"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.5",
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

这是包的my composer.json:

{
  "name": "datapage/datapage-sdk-laravel",
  "description": "Datapage SDK",
  "authors": [
    {
      "name": "Márcio Winicius",
      "email": "marciowinicius.mw@gmail.com"
    }
  ],
  "autoload": {
    "psr-4": {
      "Datapage\\DatapageSDK\\": "src/Application"
    }
  },
  "extra": {
    "laravel": {
      "providers": [
        "Datapage\\DatapageSDK\\Providers\\DatapageSDKProvider"
      ],
      "aliases": {
        "DatapageSDK": "Datapage\\DatapageSDK\\Facades\\DatapageSDK",
        "HttpClient": "Datapage\\DatapageSDK\\Facades\\HttpClient",
        "OAuthClient": "Datapage\\DatapageSDK\\Facades\\OAuthClient"
      }
    }
  },
  "require": {
    "php": ">=7.0"
  },
  "require-dev": {
    "phpunit/phpunit": "~5.7"
  },
  "config": {
    "bin-dir": "bin/"
  }
}

这是我的包结构,其中提供程序是:

src\Application\Providers

这是我的提供者:

<?php

namespace Datapage\DatapageSDK\Providers;

use Datapage\DatapageSDK\Auth\OAuthClient;
use Datapage\DatapageSDK\DatapageSDKFactory;
use GuzzleHttp\Client;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;

class DatapageSDKProvider extends ServiceProvider
{
    protected $defer = true;

    public function boot()
    {
        $this->publishes([
            __DIR__.'/../../config.php' => config_path('datapage_sdk.php'),
        ], 'datapage-sdk-config');
    }

    public function register()
    {
        $this->app->singleton('DatapageSDK', function() {
            return new DatapageSDKFactory();
        });

        $this->app->singleton('OAuthClient', function() {
            return new OAuthClient(new Application());
        });

        $this->app->singleton('HttpClient', function() {
            return new Client([
                'headers' => [
                    'Authorization' => \Datapage\DatapageSDK\Facades\OAuthClient::getToken()
                ]
            ]);
        });

        $this->app->bind(DatapageSDKFactory::class, 'DatapageSDK');
        $this->app->bind(OAuthClient::class, 'OAuthClient');
        $this->app->bind(Client::class, 'HttpClient');
    }

    public function provides()
    {
        return [
            DatapageSDKFactory::class, 'DatapageSDK',
            OAuthClient::class, 'OAuthClient',
            Client::class, 'HttpClient',
        ];
    }
}

编辑:刚刚更改了我的laravel项目的composer.json,如下所示:

"repositories": [
        {
            "type": "vcs",
            "url": "http://git2.datapage.com.br/ms/datapage-sdk-laravel.git"
        }
    ],

换言之:

"ms/datapage-sdk-laravel": "dev-develop"

然后编写器更新和编写器转储自动加载

共有1个答案

葛宪
2023-03-14

您需要在require或requiredev中使用它,这取决于您使用它的目的。您可能会将它列为您需要的东西,但composer不知道如何从中安装它。

 类似资料:
  • 我正在使用multer和cloudinary构建一个图像上传应用程序。我已经使用dotenv正确配置了环境变量。然而,当我尝试使用Cloudinary上传文件时,我得到了错误“必须提供api_密钥”。 Cloudinary API凭据的提供和配置正确,如下代码所示: 阴云密布。js 埃文先生 这个env文件在我的应用程序中也是正确必需的。js文件: app.js 如果我在cloudinary.js

  • 我怎么解决这个问题? http://localhost:3000/favicon.ico404(未找到) 服务器有此错误消息: 找不到404错误:在D:\nodetour\app中找不到。第二层的js:82:13。句柄[作为句柄\u请求](D:\nodetour\node\u modules\express\lib\router\layer.js:95:5)位于trim\u前缀(D:\nodeto

  • 我在我的类上收到三条错误消息,它说在、和上找不到符号。我该如何解决这个问题?我试图在对话框中打印出来,但这三个是唯一不起作用的。

  • 我有Xcode6.2测试版。正在尝试 在中产生 Xcrun:错误:找不到实用工具“simctl”,不是开发人员工具或在路径中

  • 任何帮助都将不胜感激。谢谢! 运行“npm run build”20:43:24.926 tdwcks@1.0.0build/vercel/5ccaedc9 20:43:24.926 next build 20:43:24.967 internal/modules/cjs/loader.js:983 20:43:24.967 抛出错误;20:43:24.967 ^20:43:24.967 错误:找

  • 我已经更新了Android Studio的3.4.1版本。 立即,Android Gradle Plugin版本和Gradle版本不是最后一个版本,所以我用3.4.1和5.1.1(文件>项目结构>项目)进行了更改。 现在,我试图创建一个apk,但出现错误“无法找到com.Android.tools.Build:Gradle:3.4.1”。 该项目是用cordova创建的,首先我在9.0.0版本上更