简体   繁体   English

找不到类'Memcache'和PHP

[英]Class 'Memcache' not found & PHP

I installed memcached by reading this article on Windows7 but unfortunately i keep getting error Fatal error: Class 'Memcache' not found in D:\\xampp\\htdocs\\test\\memcache\\test.php on line 2 我在Windows7上阅读这篇文章安装了memcached但不幸的是我一直收到错误Fatal error: Class 'Memcache' not found in D:\\xampp\\htdocs\\test\\memcache\\test.php on line 2

Line 2: $memcache = new Memcache; 第2行: $memcache = new Memcache;

Win7 64, Xampp Installed. Win7 64,已安装Xampp。 I am using net start "memcached Server" on command line but it says service is already started. 我在命令行上使用net start "memcached Server" ,但它说服务已经启动。

Some other info which may help; 其他一些可能有帮助的信息;

On php.ini file: 在php.ini文件中:

extension=php_memcache.dll

    [Memcache]  
    memcache.allow_failover = 1  
    memcache.max_failover_attempts=20  
    memcache.chunk_size =8192  
    memcache.default_port = 11211  

Update: phpinfo(); 更新:phpinfo(); show dll is not loaded. show dll未加载。 Tried several different dll files so far, didn't work. 到目前为止尝试了几个不同的DLL文件,没有用。 Also dll is located correct. dll也是正确的。 It is in the right folder as it seems. 它似乎在正确的文件夹中。

(PS Some may think there are possible duplicates about this topic but there is only 1 person who followed the same instructions and had same error in SO. That question has no answer or solution since march.) (PS有些人可能认为这个主题可能有重复,但是只有一个人遵循相同的指示并且在SO中有相同的错误。自3月以来,这个问题没有答案或解决方案。)

I found the working dll files for PHP 5.4.4 我找到了PHP 5.4.4的工作dll文件

I don't knowhow stable they are but they work for sure. 我不知道他们是否稳定,但他们肯定会工作。 Credits goes to this link . 积分转到此链接

http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip

http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip

It is the 2.2.5.0 version, I noticed after compiling it (for PHP 5.4.4). 这是2.2.5.0版本,我在编译之后注意到了(对于PHP 5.4.4)。

Please note that it is not 2.2.6 but works. 请注意,它不是2.2.6但是有效。 I also mirrored them in my own FTP. 我也用自己的FTP镜像了它们。 Mirror links: 镜像链接:

http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip

Add this to your php.ini: 将其添加到您的php.ini:

extension="php_memcache.dll"

and restart apache 并重新启动apache

Memcached just uses standard text interface so its possible to use it without the module. Memcached只使用标准的文本界面,因此可以在没有模块的情况下使用它。

// connect
$link = fsockopen($host,$port,$errno,$errst,$timeout);

// set
$data = sprintf("set %s 0 %s %s\r\n%s\r\n",
            $key,$expire,strlen($value),$value);
fwrite($link,$data);
$result = trim(fgets($link));
if ($result == 'ERROR') {
    // :(
}

// get
$data = sprintf("get %s\r\n",$key);
fwrite($link,$data);
$line = rtrim(fgets($link)); 
if ($line != 'END') {
    return rtrim(fgets($link));
}

So i have looked now for a solution. 所以我现在寻找解决方案。 Here you can download some compiled extensions. 在这里您可以下载一些编译的扩展。

http://downloads.php.net/pierre/ http://downloads.php.net/pierre/

The problem is that at the moment there is no memcache extension for PHP 5.4 . 问题是目前PHP 5.4没有memcache扩展。 this is the problem why your extension could not be loaded. 这是无法加载扩展名的原因。 You need the extension for the correct PHP version and Tead Safe for Windows. 您需要正确的PHP版本和Tead Safe for Windows的扩展。

So the easiest way is to work with PHP 5.3 if you need the extension. 因此,如果您需要扩展,最简单的方法是使用PHP 5.3

The newest version of memcache is the version 3.0.6 but its a beta version you can see it here. 最新版本的memcache是​​版本3.0.6,但它是测试版,你可以在这里看到它。

http://pecl.php.net/package/memcache http://pecl.php.net/package/memcache

You could try to take the beta version and compile it with your windows system. 您可以尝试使用测试版并使用Windows系统进行编译 But its a lot of work. 但它的工作很多。

Also problem can be in loading another version of php module somewhere in apache .conf files. 另外一个问题可能是在apache .conf文件中的某处加载另一个版本的php模块。 Need to check duplicated "LoadModule php..." directives and if that module compiled to correct version of apache. 需要检查重复的“LoadModule php ...”指令以及该模块是否编译为正确版本的apache。 It seems sound simply, but not when you have several versions of php on one machine :) Or it can be SElinux problem too. 这看起来很简单,但不是当你在一台机器上有几个版本的PHP :)或者它也可能是SElinux问题。

xampp windows version is 32bit ,you must be use 32bit memcache.dll xampp windows版本是32bit,你必须使用32bit memcache.dll

I hole that would be useful for you! 我的洞对你有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM