I am trying to setup php memcached extension on mac OS High Sierra. I am running php 7.2
Output of php -v:
PHP 7.2.6 (cli) (built: May 25 2018 06:18:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies
I installed memcached via pecl
without any error:
pecl install memcached
It is enabled in php.ini file:
extension="memcached.so"
When I run <?php echo phpinfo();?>
on my Apache server. I can see session configured:
session.save_handler memcached memcached
My symfony application gives me still this error:
(1/1) ClassNotFoundException
Attempted to load class "Memcached" from the global namespace.
Did you forget a "use" statement?
EDIT:
My apache is running a different version of php (PHP Version 7.1.16) I don't know why but I think this cannot be a problem.
In info file I can see in the CORE section that php extension dir is "/usr/local/lib/php/pecl/20170718"
. When I open that directory there is memcached.so
file. The path is correct.
EDIT 2:
In my apache logs I see warning:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20170718/memcached.so' - dlopen(/usr/local/lib/php/pecl/20170718/memcached.so, 9): Symbol not found: _zend_empty_string\n Referenced from: /usr/local/lib/php/pecl/20170718/memcached.so\n Expected in: flat namespace\n in /usr/local/lib/php/pecl/20170718/memcached.so in Unknown on line 0
So. Apache and SLI php version use diferent php.ini files. For examle on my Debian 9 it use /etc/php/7.2/apache2/php.ini and /etc/php/7.2/cli/php.ini
I believe your problem is that you are using a different version of PHP.
Just try comands below:
$sudo a2dismod php7.1
$sudo a2enmod php7.2
$sudo service apache2 restart
If you still get same Error try create info.php in your www root dir thich conteint next code:
<?php
phpinfo();
And check Memcache are loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With