找不到 PHP 5.4 和 Laravel 类“Memcached”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27991908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP 5.4 & Laravel Class 'Memcached' not found
提问by Bill Garrison
I realize there are about 10 of these questions out there but none fit me completely.
我意识到大约有 10 个这样的问题,但没有一个完全适合我。
Steps completed:
完成的步骤:
- Installed memcache
- installed php memcache module
- updated laravel config to use memcache
- Restarted server
- 安装内存缓存
- 安装 php memcache 模块
- 更新 Laravel 配置以使用 memcache
- 重启服务器
php info results:
php信息结果:
memcache.allow_failover 1 1
memcache.chunk_size 8192 8192
memcache.default_port 11211 11211
memcache.default_timeout_ms 1000 1000
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.max_failover_attempts 20 20
memcached-tool results:
memcached-tool 结果:
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 14
bytes_written 1096
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 0
cmd_get 0
cmd_set 0
cmd_touch 0
conn_yields 0
connection_structures 6
crawler_reclaimed 0
curr_connections 5
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 0
delete_misses 0
evicted_unfetched 0
evictions 0
expired_unfetched 0
get_hits 0
get_misses 0
hash_bytes 524288
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 2.0.21-stable
limit_maxbytes 268435456
listen_disabled_num 0
lrutail_reflocked 0
malloc_fails 0
pid 12022
pointer_size 64
reclaimed 0
reserved_fds 20
rusage_system 0.043400
rusage_user 0.065101
threads 4
time 1421438137
total_connections 7
total_items 0
touch_hits 0
touch_misses 0
uptime 2607
version 1.4.21
It is in php -m as "memcache"
它在 php -m 中作为“memcache”
However, when i go into php artisan tinker and try to do any caching I get the typical Fatal error: Class 'Memcached' not found in vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php on line 44
但是,当我进入 php artisan tinker 并尝试进行任何缓存时,我得到了典型的 Fatal error: Class 'Memcached' not found in vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php on line 44
TL;DR;
TL; 博士;
I have confirmed install of memcache through multiple methods. Confirmed the module for php is installed. Still not allowing me to use memcached class.
我已经通过多种方法确认安装了 memcache。确认已安装 php 模块。仍然不允许我使用 memcached 类。
回答by juaniiton1
If you are in a ubuntu environment, try to install Memcached with this:
如果您在 ubuntu 环境中,请尝试使用以下命令安装 Memcached:
sudo apt-get install php5-memcached
sudo apt-get install php5-memcached
After that restart your server with
之后重新启动您的服务器
sudo service lighttpd restart
sudo service lighttpd restart
or
或者
sudo service apachectl2 restart
sudo service apachectl2 restart
or
或者
sudo service nginx restart
sudo service nginx restart
回答by Daniel Williams
Memcache
and Memcached
are two different PHP extensions. Memcache
is the older deprecated one. Memcached
is a much newer and fully supported extension.
Memcache
并且Memcached
是两个不同的 PHP 扩展。Memcache
是较旧的已弃用的。Memcached
是一个更新且完全受支持的扩展。
Check out http://pecl.php.net/package/memcached
查看http://pecl.php.net/package/memcached
You may need to also install libmemcached
https://launchpad.net/libmemcached/+download
您可能还需要安装libmemcached
https://launchpad.net/libmemcached/+download
回答by Nizar B.
apt-get install php-memcached
Solved the issue for "Class MemCached not found" coming from Laravel.
解决了来自 Laravel 的“找不到类 MemCached”的问题。
回答by DaranaSV
In Laravel/Lumen 5.4 just replace the CACHE_DRIVER=file in .env file, the artisan command will work perfectly, But you will not get all the command as same as laravel.
在 Laravel/Lumen 5.4 中只需替换 .env 文件中的 CACHE_DRIVER=file,artisan 命令将完美运行,但您不会获得与 Laravel 相同的所有命令。