How to install PHP 7 extension "memcache" on Windows
Asked Answered
L

1

6

I'm having huge problems installing memcached extension for php.

Currently using:

OS: Windows 10 x64
PHP: 7.0.1 via XAMPP
Apache: 2.4.18 (Win32)

I have successfully installed memcached in C:/memcached the service is running.

But the problem starts when trying to add the memcache php extension. I've tried numerous versions of php_memcache.dll and non seem to be working.
I did include the extension in php.ini extension=php_memcache.dll

When i run php -m memcache is not listed and at the top i recieve the error:

PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_memcache.dll'
- The specified module could not be found.

And when I try running a test.php for memcache initialization i recive the Class not found exception

This is a huge problem, because I need it for running selenium tests.

Ladykiller answered 23/8, 2016 at 17:6 Comment(5)
Did you check that path to make sure the file exists? Because PHP is saying it doesn'tCulverin
github.com/nono303/PHP7-memcahe-dllKuching
@Spartan Thank you for replying, that link seems quite useful. But please could you give me pointers (this is my first time adding an extension). Am i supposed to just add the .dll file in php/ext and add the line in php.in? I did it and still the problem remains the same.Ladykiller
Thanks @Sherif , and yeah that makes a huge difference unfortunately.Ladykiller
memcached with a D over here: #4396821Pouched
S
12

The memcached service doesn't actually install the PHP memcached extension for you. It only installs the memcached server used to store your cache.

You'll need to download the Windows DLL from the PECL repository first (click on the blue Windows DLL link). Then you must add the extension=php_memcache.dll line to the correct php.ini file for your SAPI. Also, note the extension DLL file needs to be placed in the correct path for your XAMPP installation.

For Apache, simply create a script in your document root with the line <?php phpinfo(); and try loading that in your web browser. You should see a line at the top labeled Loaded configuration (php.ini) which gives you the full path to your loaded php.ini file. On Windows the path may actually appear different than what is stated in phpinfo() if you installed PHP through something like XAMPP. So you may need to rely on XAMPP to locate the correct php.ini file.

For the CLI SAPI, you can use php.exe --ini to do the same. Again, you may need to rely on the XAMPP package if it has modified your configuration path (since this is a compile time directive).

After making your changes to php.ini you will need to restart PHP for the changes to take effect.


Since you're using PHP 7 on Windows it's probably also important to note that the compiled DLL from PECL may not actually work under apache for Windows, because you're more than likely using a theaded SAPI. So make sure you are downloading the correct version. As far as I can tell that version is only compiled to work with up to PHP 5.6. The github alternative, for PHP 7, available at https://github.com/nono303/PHP7-memcahe-dll as mentioned in the comments is tested under non-thread safe. So you may only be able to get this working for your CLI scripts on Windows.

Staffan answered 23/8, 2016 at 17:52 Comment(4)
Thank you so much for taking the time to write such a detailed response. Yes, I know it doesn't and i tried downloading every single .dll file they offered at PECL, but to no avail. The extension=php_memcache.dll has been added in my php.ini, as the guides pointed out. And the dll file was placed along with the others C:\xampp\php\ext. But STILL memcache is not on the phpinfo() or php -m list. The php -m list still gives the mentioned error. + I did restart Apache after making the changes.Ladykiller
Ahhh I have not tried ALL of the dll-s from that repository... The x86 ts did the trick. Thanks a lot @Staffan :]Ladykiller
Great, glad to know it worked. Trying the wrong version is usually one of the most common mistakes people have with this issue on Windows.Staffan
This is for memcache not memcachedPouched

© 2022 - 2024 — McMap. All rights reserved.