Laravel Lumen Memcached not found

房东的猫 提交于 2019-12-02 17:37:21

You may need to restart your server, especially if you're using 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.

Zl3n

I spent 3 hours on this problem today. With the help of the post of demve in this topic, I found the solution. Very simple ! I hope it won't affect me later in my development.

Just to it, in the .env file :

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=array

Ok, I make an UPDATE because I was faced to a new problem about session. In fact, when you set the previous parameters, your session won't be persistant, like said in the documentation : array - sessions will be stored in a simple PHP array and will not be persisted across requests.

So I have change it, always in .env file like that :

SESSION_DRIVER=cookie

With a var_dump(Session::all()); I now can see the whole values of my session

In .env file replace

#This line:- 
  CACHE_DRIVER = memcached

#With this:- 
   CACHE_DRIVER = array

Make sure not to get caught out by your .env file not being loaded, which by default it's commented out in Lumen. So if you are specifying a different cache driver in your .env, do the following.

Note: If you are using the .env file to configure your application, don't forget to uncomment the Dotenv::load() method in your bootstrap/app.php file.

Source: http://lumen.laravel.com/docs/cache

in your .env file, you can also use CACHE_DRIVER=file instead of CACHE_DRIVER=memcached

This issue resolved when i installed this package so try at least

First i tried this and it works fine

CACHE_DRIVER = array 

but then thought about what is memcached

Then i tried this and it works fine without changing driver memcached

apt-get install php-memcached 

In my case i added Add CACHE_DRIVER=array in .env file
Then

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

in my bootstrap/app.php and the .env file started working.

For me, the issue was that I used the php-7 branch of homestead repository which does not have PHP memcached ready.

I had a similar problem now, I couldn't track it down but my guess is that it has something to do with the fact that the defaults configurations are stored in the vendor/laravel/lumen-framework/config folder, the DotEnv::$inmutable setting and the artisan serveserver.

The solution that worked for me was:

  1. Add in bootstrap/app.php the following: Dotenv::makeMutable(); Dotenv::load(__DIR__.'/../'); Dotenv::makeImmutable();

  2. in the .env file, set all the configuration to "basic drivers" (array, file) even if you are not going to use them, because you w

If you have a new lumen installation, you must rename .env.example to .env . So it can read your configurations!

This happens if your .env file is owned by another user than the one trying to run the artisan command.

Heinrich Boers

Check if memcached is installed, if not install it by running:

apt-get install php5-memcached
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!