好的,我刚开始使用Lumen,我正在try 使用Auth,但是调用Auth::Check或Auth的任何其他函数.导致以下错误 Fatal error: Class 'Memcached' not found in vendor\illuminate\cache\MemcachedConnector.php on line 52美元. 我不想使用memcached,以前从未使用过它.

I disabled it in the .env file and set the CACHE_DRIVER and SESSION_DRIVER to array, but still shows the same error.

我决定不再使用Auth,而是手动处理会话/令牌的身份验证,但启用中间件StartSession会导致相同的错误.

$app->middleware([
 // 'Illuminate\Cookie\Middleware\EncryptCookies',
 // 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
  'Illuminate\Session\Middleware\StartSession',
 // 'Illuminate\View\Middleware\ShareErrorsFromSession',
 // 'Laravel\Lumen\Http\Middleware\VerifyCsrfToken',
]);

Please I'd be so glad if anyone can really help me out here

EDIT

After going A little Deep in the framework I Hard Coded the session driver name in the SessionManager Class within the method getSessionConfig

public function getSessionConfig()
{
    $this->setDefaultDriver("cookie");//I added this line
    return $this->app['config']['session'];
}

不过,这很管用,但不是一种好的做事方式. 没有配置文件,我相信所有的配置都是写在.env文件中的,但是我真的不知道为什么SESSION_DRIVER和CACHE_Driver在.env中更改后都默认为memecached,然后运行composer dump-autoload.Lumen :(

EDIT This is my .env file

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomKey!!!

APP_LOCALE=en
APP_FALLBACK_LOCALE=en

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=cookie
QUEUE_DRIVER=database

I already have this line uncommented in my bootsrap/app.php

 Dotenv::load(__DIR__.'/../');

我的数据库配置运行良好,因此.env文件已加载

推荐答案

您可能需要重新启动服务器,尤其是在使用php artisan serve的情况下.

Lumen doesn't appear to pick up .env changes per-request.

I had exactly the same issue - trying to use file cache, but received errors regarding Memcached - restarting the server reloads the .env file.

Laravel相关问答推荐

Laravel将变量从模板到已发布的供应商模板

从 Laravel 中的值开始主键

在 laravel 5.3 中截断的错误日志(log)

Laravel & Docker:无法打开流或文件/var/www/html/storage/logs/laravel.log:无法打开流:权限被拒绝

Laravel PHP 框架的新手. /以外的路由不起作用

错误try 访问 null 类型值的数组偏移量laravel 5.8.26 Php 7.4.2

验证规则 required_if 与其他条件(Laravel 5.4)

如何监控 Laravel 队列是否正在运行?

Laravel 5.2 中的正则表达式验证

Laravel 5.5 在迁移文件中设置整数字段的大小

artisan 迁移错误找不到类'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver'

Laravel 4 的 Cron 作业(job)

Homebrew PHP 似乎没有链接

Http请求多浏览器的烦恼

如何访问 Carbon 对象类型?

Laravel 初学者的良好开端

如何在 vs 代码中自动导入 laravel 类

Laravel - 使用 Eloquent 查询构建器在 Select 中添加自定义列

Laravel 集合计数结果

Distinct values with pluck