How to install PHP 7 extension "memcache" on Windows - php

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.

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.

Related

PHP 8.0.12 upgrade to PHP 8.1 - multiple module errors

I've been making upgrades on my Dev workstation using XAMPP for a long time now, from the various version 7s up through 8.012.
I seem to have hit a wall upgrading to 8.1.
I've edited the apache config to use the new version of php. Taking the php.ini-development and renaming it to php.ini, then uncommenting the openssl extension has no effect after I restart apache:
extension=openssl
Openssl isn't enabled in the php info page:
And if I try and enable mongodb by moving my extension over from the previous installation, and uncomment the extension in php.ini and restarting apache again I get an error:
extension=php_mongodb.dll
Update: I now find that enabling ANY PHP module does not work under PHP 8.1.
I can roll back to the previous version of php-8.0.12 and have a fully functioning php again. When I roll back to the previous version enabling and disabling PHP modules still works. It does not work under PHP 8.1.
I'd like to stay up to date with the latest release if at all possible!
What am I doing wrong with this version of PHP? Why can't I enable anything?
I've had to set the FULL PATH to the extensions directory on Windows. Once I did that and restarted, I was able to enable / disable extensions. Look for this line in php.ini and adjust it to your needs:
; On windows:
extension_dir = "C:\xampp\php-8.1.0\ext\"
This setting only seems important on Windows. Set that line the way you want it, restart apache and you should be good to go!
You are copying an incompatible module compiled with the older version. If you are upgrading the PHP version, You'll need an extension DLL file compiled with that specific version of PHP and suitable for your server environment. You can download the compatible packages from here PECL. Download and put the .dll file in your extension directory. Then, you'll need to enable that extension.
Here is the guide for the windows system Installing a PHP extension on Windows.
For MongoDB, get it here https://pecl.php.net/package/mongodb

php.ini extension not found Windows 10 [duplicate]

I run a PHP script and get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/ixed.5.2.lin' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/ixed.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0
What does that mean?
It means there is an extension=... or zend_extension=... line in one of your php configuration files (php.ini, or another close to it) that is trying to load that extension : ixed.5.2.lin
Unfortunately that file or path doesn't exist or the permissions are incorrect.
Try to search in the .ini files that are loaded by PHP (phpinfo() can indicate which ones are) - one of them should try to load that extension.
Either correct the path to the file or comment out the corresponding line.
If you're on Linux, you can find all loaded configuration files by typing this in shell:
php -r "print phpinfo();" | grep ".ini"
UPDATE:
As mentioned in comments, this can be even more accurate:
php -i | grep ini
phpStom with XAMPP
TL;DR Except from verifying that the files exist, you might need to add the drive letter to some records in your php.ini file
I suddenly started having a problem using phpStorm 7 for debugging php with xampp and xdebug. When trying to set intellij interperter to be xampps php I got a lot of the warnings like the one in the question, for example:
Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'
For some reason I had to add my drive letter to the records of extension_dir and browscap in the php.ini file:
extension_dir = "\xampp\php\ext"
browscap = "\xampp\php\extras\browscap.ini"
to
extension_dir = "e:\xampp\php\ext"
browscap = "e:\xampp\php\extras\browscap.ini"
If you just want to make the error disappear, and you don't need the extension, then by all means comment the line out in php.ini. But if you actually want to fix the problem here is some additional info.
There are various causes for this based on the exact module, but there are also some general guidelines.
Open phpinfo() and look for extension_dir under the Core section. This is where your modules should be located.
For instance, /usr/lib/php/modules for Unix/Linux.
If the file does in fact exist, make sure permissions are adequate.
If the file does not exist, use the resources below to install it.
Installation on *nix (PEAR)
Installation of extensions on Windows
Loading .dll in Linux
I've encountered this warning message while I was trying to install a php-extension via the php.ini file;
until I figured out that you cannot load .dll extensions in Linux,
but you have to comment the extensions that you want to import ;extension= ... .dll and install it correctly via sudo apt-get install php-...
note: ... is the extension name you want to enable.
php -r "echo php_ini_loaded_file();"
Will show in CLI current ini loaded file, search there for Your extension, path to it is incorrect.
In my case, this message started to appear when I updated the php version to 7.4.
To solve it I had to look for the php.ini files found inside the php version folder (/etc/php/7.4/apache2/ && /etc/php/7.4/cli/) checking the lines where the extensions I could see that the extensions gd2 and intl were uncommented.
Note that you can also get this error if your PHP library doesn't have the "other" directory opening permission. In my particular case, I noticed this when using php -l to syntax check a script in my text editor. This meant that since my account was called "volomike", that account didn't have permission to run the libraries that the php command relied upon.
For instance, on Ubuntu 14.04, I had PHP5 installed automatically into the path /usr/lib/php5/20121212+lfs. However, because I was working in C++ in building some shared objects, I messed around with the directory permissions and screwed things up such that non-root accounts did not have the directory execute (directory open) permissions to view /usr/lib/php5/20121212+lfs. So, I typed the following command to rectify that problem:
sudo chmod o+x /usr/lib/php5/20121212+lfs.
Now when I do php -l example.php as a non-root user, it never gives me this "Unabled to load dynamic library" problem anymore.
I had the same problem on XAMPP for Windows when I try to install composer.
I did php -v and php throwing error :
Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'
It took me a while until I realized that I need to setup my XAMPP. So I run setup_xampp.bat and php return to works like a charm.
I had this error on a number of modules when I had been running different versions of PHP side by side on my server. To sort this out, I needed to install the packages it couldn't find for that specific PHP version. So, for example, if I saw:-
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/xml.so'
I would install the library for the PHP version specifically:-
sudo apt-get install php7.1-xml
And then restart Apache. Fixed it for me. You can check your version like this:-
php -v
I had the same problem on XAMPP for Windows10 when I try to install composer.
Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'
Then follow this steps
just open your current_xampp_containing_drive:\xampp(default_xampp_folder)\php\php.ini in texteditor (like notepad++)
now just find - is the current_xampp_containing_drive:\xampp exist?
if not then find the "extension_dir" and get the drive name(c,d or your desired drive) like.
extension_dir="F:\xampp731\php\ext" (here finded_drive_name_from_the_file is F)
again replace with finded_drive_name_from_the_file:\xampp with current_xampp_containing_drive:\xampp and save.
now again start the composer installation progress, i think your problem will be solved.
What I did was;
1 - I first find out what version of PHP I am using thru the function phpinfo()
<?php
phpinfo();
?>
2 - From there you will find the location of your configuration(php.ini) file
3 - Open that file
4 - Comment out the line similar to the image below
This might be a different value but it should be related to extension.
I am no expert but this process helped me solved similar problem.
In my case I got this error because I downloaded a thread-safe version of the dll (infixed with -ts-), but my installation of php was a non-thread-safe (infixed with -nts-). Downloading the right version of the dll, exactly matching my php installation version fixed the issue.
After Windows 10 XAMPP now I installed LAMPP (XAMPP) on Ubuntu. Windows XAMPP had a lot less to configure compare to MAC (iOS) but now with Linux Ubuntu I had a few more since there are more going in Linux (a good thing).
I confused and activated mysqli.dll (and mysql.dll: erase "#" in /etc/php/7.2/cli/php.ini
I started to get the PHP Warning: PHP Startup: Unable to load dynamic library message related to dll. I commented out mysql(and i).dll in the same file but the message didn't go away up until I commented out " " in /opt/lampp/etc/php.ini.
Looks like XAMPP reads php.ini file from /etc/php/7.2/cli and makes modification in php.ini of /opt/lampp/etc. (;extension=php_pdo_mysql.dll after ";" restarted Apache and no more any message.
I encountered a similar error. The mistake I made was to use the "controller" name as "Pages" instead of "pages" in my url.
In Windows, it could be a wrong path in "System environment variables".
"Path" to the php.exe directory must be the good one.
'C:/PHP/5.2.13/ext\php_mcrypt1.dll'
I'd say there's some typo on your php.ini (the extra 1). Perhaps you're loading a different php.ini from what you expect (see the output of php.ini to make sure).
Other than that make sure that php_mcrypt.dll and PHP:
Were linked to the same VC runtime library (typically msvcrt.dll for VC6 or msvcrt90.dll for VC9) – use e.g. the dependency walker for this
Are both debug builds or both release builds
Both have ZTS enabled or ZTS disabled
For libraries that depend on further libraries (DLLs), make sure they are available (e.g. in the same directory as the extension)
PHP should give you meaning errors if any of the first three conditions above is not satisfied, but I wrote those anyway because I'm not sure for PHP 5.2.
From C:\xampp\php\php.exe I got
Unable to load dynamic library ''
C:\xampp\php\ext\php_.dll (The specified module could not be found.)
I solved by commenting out
C:\xampp\php\php.ini
;extension=
I had the same problem when I tried to use php with sql server, when I added the sqlsrv libraries ... it gave me the error, after several days of researching there, I understood that microsoft does not support x64 in this case so what I did was install laragon x86 and use the corresponding libraries. I hope it helps with something
Go to system env variable and set the php ext dir path as
C:\xampp\php\ext
basically it's finding the ext directory and then locating it's file but it's unable to find the files becuase php path is set as different.

Configuring mongodb on MAMP

So I've tried almost all the tutorials I've found here and on other sources but the problem is always the same. The extension is not installed when I call the phpinfo method.
I've added the file mongo.so to the extensions folder and I've called it on the php.ini as extension=mongo.so.
I'm using MAMP 2.2 on Mavericks and the php version is 5.5.3.
Appreciate any kind of help.
The output of phpinfo() will tell you which php.ini file (if any) is in use.
You have to modify that php.ini file and add extension=mongo.so and then restart your webserver.
One thing you need to keep in mind when you are installing the MongoDB driver for MAMP is the pecl command you are using is actually the MAMP command, not some alternative PHP install you may have on your system.
To do this, locate the PHP binary distributed with MAMP, and the use the full path to the pecl command of the MAMP installation.

installing PHP APC extension on windows

I want to install the APC extension for PHP. I've got to this page and I'm a little stuck.
I've downloaded a file from here, which gives me a APC-3.1.9.tgz file.
I've extracted the file. However from the page I've mentioned above, I'm given the impression I need to load a .dll file.
I'm lost and confused, what should I be doing?
OS: Windows Vista
Server: Apache
PHP: 5.3.5
You can download the compiled dll from downloads.php.net.
From http://www.php.net/manual/en/apc.installation.php
A DLL for this PECL extension is currently unavailable. See also the
building on Windows section.
In other words: no easy way on Windows
I downloaded the file from above mentioned http://downloads.php.net/pierre/. The zip contains two folders: "nts" and "ts" (probably "tread safe" and "non thread safe") with php_apc.dll file.
You must put this file in your PHP extensions folder (for exemple c:\wamp\bin\php5.4.1\ext) and edit PHP.ini file to add or uncomment the line:
extension=php_apc.dll
After restarting web service (Apache, IIS, etc.) you can check the PHP configuration with
<?php phpinfo(); ?> to see if "apc" block appeared
Here's hoping people looking for APC for Windows are still checking this post.
I just found APC 3.1.9 for Windows here:
http://dev.freshsite.pl/php-accelerators/apc.html
Confirmed working on Apache 2, PHP 5.3.8, Windows 7 (32-bit).
try this Alternative PHP Cache (APC) 3.1.9 extension
https://code.google.com/p/xampp-php-extensions/downloads/detail?name=php_apc.dll&can=2&q=

installing php cURL on IIS

I cannot install PHP-CURL on IIS. I think I have tried everything.
My phpinfo() output does not list cURL as available.
I have C:\PHP in my path and working correctly.
I have edited the registry to read from C:\PHP\php.ini. phpinfo() output shows the correct .ini path loaded.
I have uncommented 'extension=php_curl.dll'
I have ssleay32.dll and libeay32.dll availble in C:\PHP
Windows Server 2003
IIS 6
PHP 5.2.4
Try running:
php-cgi.exe -v
and see if any errors come up.
Also make sure the php is correctly in your path by going to the command line and typing:
echo %PATH%
As well make sure the php_curl.dll is in the correct directory and that ssleay32.dll and libeay32.dll are the same versions.
If all else fails try reinstalling PHP as I remember there being some issues a while back with the Curl Module not working on 5.1.4.
As well someone else mentioned installing the thread safe PHP package versus the non-thread package resolving a similar issue.
Did you definitely put php_curl.dll in the directory that PHP reads extensions from? Are the file permissions on it ok? And the big question: where did you get the php_curl.dll from? If you got a precompiled one it might be compiled for a different version of PHP than you are running. Check your webserver logs and see what comes up from PHP when you restart the server/container/whatever.

Categories