swagger - Lumen 中的 DarkaOnline 招摇集成未注册 Swagger\Lume::ServiceProvider
问题描述
我正在尝试将 swagger 集成到 mu lumen 项目中。Lumen 版本是 5.7 在我的本地系统中它工作正常,但在服务器(Ubuntu)中,由于内存问题我无法遵循命令,所以我将供应商文件夹、composer.json 和 composer.lock 文件从本地上传到服务器,我运行 composer dump-autoload 命令。
我按照这个文档进行了招摇集成。
https://github.com/DarkaOnLine/SwaggerLume
然后在我的终端中运行 php artisan swagger-lume:publish
但我得到了
在 Apllication.php 第 183 行中找不到类“SwaggerLume\ServiceProvider”
我已经配置了我的 bootstrap/app.php 文件,如下所示
未注释 $app->withFacades(); 并添加了 $app->configure('swagger-lume'); 在注册容器绑定之前。我添加了 $app->register(\SwaggerLume\ServiceProvider::class); 里面注册服务提供者。
<?php
require_once __DIR__.'/../vendor/autoload.php';
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
$app->withFacades();
$app->withEloquent();
$app->configure('swagger-lume');
/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/
$app->register(App\Providers\AuthServiceProvider::class);
$app->register(\SwaggerLume\ServiceProvider::class);
解决方案
推荐阅读
- c++ - 从 CGAL 3D 网格生成中获取 -6.27744e+66 的顶点坐标:mesh_implicit_sphere 示例
- java - 使用列字段名称删除一行 - SQlite (SQLiteOpenHelper Android)
- javascript - 将字符串从 onclick 传递给 Javascript 函数
- firebase - AngularFireAuth:无法读取未定义的属性“GoogleAuthProvider”
- android - 即使满足“如果条件”,按钮也不会设置为启用
- javascript - 反应组件中的错误传递道具
- ruby - 在 GitHub 页面上安装 Jekyll 3.8.5
- html - 客户点击加入购物车后有没有办法去结账页面(BigCartel网友主题)
- flutter - 向 MaterialPageRoute 添加过渡
- javascript - 嘿,我怎样才能验证用户名和密码?似乎javascript没有得到值