Laravel Illumb\\Support\\Manager::createDriver()缺少参数1
我查看了与Laravel中此错误相关的所有帖子:Laravel Illumb\\Support\\Manager::createDriver()缺少参数1,laravel,laravel-5.4,lumen,laravel-middleware,Laravel,Laravel 5.4,Lumen,Laravel Middleware,我查看了与Laravel中此错误相关的所有帖子: /** * Create a new driver instance. * * @param string $driver * @return mixed * * @throws \InvalidArgumentException */ protected function createDriver($driver) { // We'll check to see if a creator method exists f
/**
* Create a new driver instance.
*
* @param string $driver
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected function createDriver($driver)
{
// We'll check to see if a creator method exists for the given driver. If not we
// will check for a custom driver creator, which allows developers to create
// drivers using their own customized driver creator Closure to create it.
if (isset($this->customCreators[$driver])) {
return $this->callCustomCreator($driver);
} else {
$method = 'create'.Str::studly($driver).'Driver';
if (method_exists($this, $method)) {
return $this->$method();
}
}
throw new InvalidArgumentException("Driver [$driver] not supported.");
}
他们都没有解决我的问题:我使用的是Laravel Lumen版本5.4和
我想访问传入请求中经过身份验证的用户:
$request->user(); //returns an instance of the authenticated user
但是,这会给我带来一个错误,即:
Illumb\Support\Manager::createDriver()缺少参数1,在第88行的/var/www/html/myApp/vendor/Illumb/Support/Manager.php中调用并定义“
我知道,为了获得经过身份验证的用户,您需要在路由中提供身份验证中间件:
$api->get('register/{accountId}', ['middleware' => 'auth', 'App\Http\Controllers\Api\V1\RegisterController@registerAction']);
但是在我的路由中添加中间件Auth实际上不会到达控制器端点,并抛出与上面所看到的相同的错误
我已在我的bootstrap/app.php中注册了AuthServiceProvider:
$app->register(App\Providers\AuthServiceProvider::class);
这是AuthServiceProvider类:
<?php
namespace App\Providers;
use App\Models\Account;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider {
/**
* Register any application services.
*
* @return void
*/
public function register() {
}
/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot() {
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return Account::where('api_token', $request->input('api_token'))->first();
}
});
}
}
我可以在stackTrace中看到,它在createDriver()方法中传递了一个NULL驱动程序,这导致了我所遇到的错误。我想知道这是否是我必须在.env文件中添加的一个简单配置
我从Laravel Lumen开始,它是构建API的一个很好的工具,我不会责怪工具本身(我花了很多时间阅读了漂亮的文档),我很确定我错过了一些非常简单的东西,如果有人能指导我,我会很高兴的。你在使用(搜索驱动程序)吗
我在运行数据库种子时遇到了您看到的错误。最后,我意识到我疲惫的头脑忘记了在我的.env文件中定义正确的env变量,如下所示:
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=yourAlgoliaAppId
ALGOLIA_SECRET=yourAlgoliaSecret
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "elasticsearch", "null"
|
*/
'driver' => env('SCOUT_DRIVER'),
/*
|--------------------------------------------------------------------------
| Index Prefix
|--------------------------------------------------------------------------
|
| Here you may specify a prefix that will be applied to all search index
| names used by Scout. This prefix may be useful if you have multiple
| "tenants" or applications sharing the same search infrastructure.
|
*/
'prefix' => env('SCOUT_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Queue Data Syncing
|--------------------------------------------------------------------------
|
| This option allows you to control if the operations that sync your data
| with your search engines are queued. When this is set to "true" then
| all automatic data syncing will get queued for better performance.
|
*/
'queue' => false,
/*
|--------------------------------------------------------------------------
| Algolia Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Algolia settings. Algolia is a cloud hosted
| search engine which works great with Scout out of the box. Just plug
| in your application ID and admin API key to get started searching.
|
*/
'algolia' => [
'id' => env('ALGOLIA_APP_ID'),
'secret' => env('ALGOLIA_SECRET'),
],
];
如果尚未发布scout配置文件,请使用以下命令执行此操作:
php artisan供应商:发布
--provider=“Laravel\Scout\ScoutServiceProvider”
在运行上述命令之前,请确保已将“Laravel\Scout\ScoutServiceProvider::class”放入“config/app.php”中的providers数组中
发布配置文件(默认名为config/scout.php)后,我使用了以下env变量:
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=yourAlgoliaAppId
ALGOLIA_SECRET=yourAlgoliaSecret
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "elasticsearch", "null"
|
*/
'driver' => env('SCOUT_DRIVER'),
/*
|--------------------------------------------------------------------------
| Index Prefix
|--------------------------------------------------------------------------
|
| Here you may specify a prefix that will be applied to all search index
| names used by Scout. This prefix may be useful if you have multiple
| "tenants" or applications sharing the same search infrastructure.
|
*/
'prefix' => env('SCOUT_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Queue Data Syncing
|--------------------------------------------------------------------------
|
| This option allows you to control if the operations that sync your data
| with your search engines are queued. When this is set to "true" then
| all automatic data syncing will get queued for better performance.
|
*/
'queue' => false,
/*
|--------------------------------------------------------------------------
| Algolia Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Algolia settings. Algolia is a cloud hosted
| search engine which works great with Scout out of the box. Just plug
| in your application ID and admin API key to get started searching.
|
*/
'algolia' => [
'id' => env('ALGOLIA_APP_ID'),
'secret' => env('ALGOLIA_SECRET'),
],
];
您正在使用(搜索驱动程序)吗
我在运行数据库种子时遇到了您看到的错误。最后,我意识到我疲惫的头脑忘记了在我的.env文件中定义正确的env变量,如下所示:
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=yourAlgoliaAppId
ALGOLIA_SECRET=yourAlgoliaSecret
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "elasticsearch", "null"
|
*/
'driver' => env('SCOUT_DRIVER'),
/*
|--------------------------------------------------------------------------
| Index Prefix
|--------------------------------------------------------------------------
|
| Here you may specify a prefix that will be applied to all search index
| names used by Scout. This prefix may be useful if you have multiple
| "tenants" or applications sharing the same search infrastructure.
|
*/
'prefix' => env('SCOUT_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Queue Data Syncing
|--------------------------------------------------------------------------
|
| This option allows you to control if the operations that sync your data
| with your search engines are queued. When this is set to "true" then
| all automatic data syncing will get queued for better performance.
|
*/
'queue' => false,
/*
|--------------------------------------------------------------------------
| Algolia Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Algolia settings. Algolia is a cloud hosted
| search engine which works great with Scout out of the box. Just plug
| in your application ID and admin API key to get started searching.
|
*/
'algolia' => [
'id' => env('ALGOLIA_APP_ID'),
'secret' => env('ALGOLIA_SECRET'),
],
];
如果尚未发布scout配置文件,请使用以下命令执行此操作:
php artisan供应商:发布
--provider=“Laravel\Scout\ScoutServiceProvider”
在运行上述命令之前,请确保已将“Laravel\Scout\ScoutServiceProvider::class”放入“config/app.php”中的providers数组中
发布配置文件(默认名为config/scout.php)后,我使用了以下env变量:
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=yourAlgoliaAppId
ALGOLIA_SECRET=yourAlgoliaSecret
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "elasticsearch", "null"
|
*/
'driver' => env('SCOUT_DRIVER'),
/*
|--------------------------------------------------------------------------
| Index Prefix
|--------------------------------------------------------------------------
|
| Here you may specify a prefix that will be applied to all search index
| names used by Scout. This prefix may be useful if you have multiple
| "tenants" or applications sharing the same search infrastructure.
|
*/
'prefix' => env('SCOUT_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Queue Data Syncing
|--------------------------------------------------------------------------
|
| This option allows you to control if the operations that sync your data
| with your search engines are queued. When this is set to "true" then
| all automatic data syncing will get queued for better performance.
|
*/
'queue' => false,
/*
|--------------------------------------------------------------------------
| Algolia Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Algolia settings. Algolia is a cloud hosted
| search engine which works great with Scout out of the box. Just plug
| in your application ID and admin API key to get started searching.
|
*/
'algolia' => [
'id' => env('ALGOLIA_APP_ID'),
'secret' => env('ALGOLIA_SECRET'),
],
];
在bootstrap/app.php
@PankitGami中取消对$app->routeMiddleware()调用的注释了吗?
是的,我在bootstrap>app.php中有这行:$app->routeMiddleware(['auth'=>app\Http\Middleware\Authenticate::class,]));它是注释的还是未注释的?@PankitGami它是未注释的,对routeMiddleware的调用在引导程序中可用。您是否在bootstrap/app.php
call中取消了对$app->routeMiddleware()的注释:$app->routeMiddleware(['auth'=>App\Http\Middleware\Authenticate::class,];它是注释的还是未注释的?@PankitGami如果未注释,则可以在引导中调用routeMiddleware。