PHP 7.2 memcached extension on Mac OS - php

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.

Related

lumen 5.6 version not working on ubuntu 16.04

I have installed fresh copy of lumen 5.6 on my ubuntu machine. I also upgrade my php version from php 5.6.* to 7.2.5. Now php 7.2.5 version is enabled on my system. But when I run the project I receive frollowing exceptoion
Parse error: syntax error, unexpected '?'
/home/example/apis/lumen/vendor/symfony/http-foundation/Response.php
Below is my php version
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Guide to solve this problem or suggest any usefull link
If you create an info.php file inside your lumen public/ folder and open it on your server
<?php // info.php filename
phpinfo();
there is a good chance it is still referencing php 5.6?
You do not mention if you are serving the project via php -S, apache or nginx.
I am going to presume you are using apache as it mostly the default on Ubuntu. Disable the php 5.6 module for apache and enable the php 7.2 module. Something like the following will work.
Disable php 5
sudo a2dismod php5
Enable php 7.2
sudo a2enmod php7.2
Restart apache
sudo service apache2 restart

Installing phpredis on Ubuntu 14.04 for PHP 7.1

My php -v
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018
11:51:39) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
I have tried both the pecl way
sudo pecl install redis
sudo service php7.1-fpm restart
And the manual way from https://github.com/phpredis/phpredis
phpize
./configure [--enable-redis-igbinary]
make && make install
I made sure to put
extension=/usr/lib/php/20170718/redis.so
into the php.ini file as shown when I run echo phpinfo();
e.g.
/etc/php/7.1/cli/php.ini
When I run the inbuilt web server I get
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/20170718/redis.so' - /usr/lib/php/20170718/redis.so:
undefined symbol: zend_empty_string in Unknown on line 0
Strangely PHPStorm autocompletes the PHP Redis class, so
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
I can click into the Redis class and see it is the correct one.
I wonder if it is a version difference? Maybe because I am using 32-bit?
Another strange thing is, if I just put
extension=redis.so
in php.ini, it seems to be looking for an older build
PHP Startup: Unable to load dynamic library
'/usr/lib/php/20160303/redis.so' - /usr/lib/php/20160303/redis.so:
cannot open shared object file: No such file or directory in Unknown
on line 0
When I run
sudo apt-get install php-redis
it installs and means that no start up error shows, but the web page still shows a
Class 'Redis' not found
One other thing I notice is that in Apache, there is no error, and the class is found. But when I run php's inbuilt web server, the not found error shows up.
May you just need to install this using a ppa package like:
sudo apt-get install php7.1-redis
Ok so I noticed that phpinfo showed
PHP API 20160303
which means that the earlier error makes sense. The PHP version of the web server is 7.1, however, when running the phpredis phpize it shows the one for 7.2.
So I just made sure to remove php7.2-dev and re-install php7.1 via apt-get, then re-run the github repo steps above.

OSX 10.10 Yosemite local development environment broke - PHP mcrypt Issue

I a running a local development environment on my MBP using osx yosemite, php 5.5.14, apache 2.4 mysql (sometimes) and a few things installed via brew.
I tried to run a CMS locally and ran into an issue where it stated i needed mcrypt; so i tried to install it and was promptly tole mcrypt was already installed.
Did a little research, tried to reinstall it and now I'm faced with this error when running php -v. Also this has stopped m dev enviroment from showing me my site and all it says now is 'it works!'
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/php55-mcrypt/5.5.21/mcrypt.so' -
dlopen(/usr/local/Cellar/php55-mcrypt/5.5.21/mcrypt.so, 9): image not
found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/php55-mcrypt/5.5.21/mcrypt.so' -
dlopen(/usr/local/Cellar/php55-mcrypt/5.5.21/mcrypt.so, 9):
image not found in Unknown on line 0
PHP 5.5.21 (cli) (built: Feb 12 2015 20:17:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Any help would be very appreciated and thanks in advance.
Make sure that you're loading the mcrypt.so extension in your php.ini file. Also, you may need to run brew install mcrypt php55-mcrypt to get the PHP extension.
Find the location of your ini with:
php -i | grep php.ini
Edit the file and add extension=mcrypt.so to the file, save and restart Apache.

MongoClient not found in PHP

I have downloaded php_mongo-1.3.2RC1.zip from https://github.com/mongodb/mongo-php-driver/downloads
Then I have extracted all of them in my C:\xampp\php\ext directory. To use mongodb though php file located in 'C:\xampp\htdocs\index.php' directory, I have added extension=php_mongo-1.3.2RC1-5.2-vc9.dll this line to C:\xampp\php\php.ini.
Yet I have got this error Fatal error: Class 'MongoClient' not found. What can I do to make it work?
I am using Xampp on windows 8 64 bit running on php 5.2.
I have tried writing php on cmd and it returns this following lines:
Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20100525
These options need to match
in Unknown on line 0
I have tried phpinfo() as #j0k has asked, and it returned:
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\xampp\php\php.ini
Try this:
pear install -f pecl/mongo
I think you use php 5.4 (info from my web server):
$ php -v; phpize -v
PHP 5.4.11 (cli) (built: Feb 10 2013 03:38:26)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
API module versions are identical.
…
Module compiled with module API=20060613
…
It is php 5.2 (from source code):
$ grep '#define ZEND_MODULE_API_NO' php-src-php-5.2.17/Zend/zend_modules.h| sed 's/#define ZEND_MODULE_API_NO//'
20060613
Check you version php (php -v; phpize -v) and setup php-mongo-driver. You can see versions in phpinfo(); (recommended; PHP API, PHP Extension, Zend Extension, Thread Safety)
Try to restart your Apache. Apache will not try to reload the configuration upon edit. For xampp you can do this in the cornor pressing shutdown or restart, if I Remember correctly. Alternative you can restart your pc
From this page:
Note: Additional DLL dependencies for Windows Users:
In order for this extension to work, there are DLL files that must be available to the Windows system PATH

Fatal error: Call to undefined function: imagecreate()

I'm trying to put some graphics on a web page and at my prototype at the computer it's all working fine at the localhost. But now I uploaded the files to a server and I'm having a problem to plot some graphics. In my computer they are plotted, but on the server they are not.
I'm getting this error
Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248
Line 248
$this->img = ImageCreate($this->image_width, $this->image_height);
I'm using phplot, and I uploaded the files form phplot too. Can anyone help me ?
Sorry for any mistake in English and thank you in advance.
This means your installation of php doesn't have the gd library installed/enabled.
http://www.php.net/manual/en/image.installation.php
If you are using a Linux machine then execute this command from console:
sudo apt-get install php5-gd
to install the php_gd2.dll extension. It will then work after an Apache restart.
PS: should first check your current php version
php -v
In My Case:
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019
10:00:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.3.5, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache
v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by
Zend Technologies
So, my PHP version is 7.3, so, the command for my version is :
sudo apt-get install php7.3-gd
Your server most like does not have GD (the built in PHP image processing library) enabled. You can check this by looking for "GD" in the output of :
<?php
phpinfo();
?>
If not, check the PHP docs on how to enable it: http://www.php.net/manual/en/book.image.php
For Fedora, CentOS
dnf install php-gd
systemctl restart httpd.service
On Ubuntu
apt-cache search php*-gd
apt-get install php<version>-gd
systemctl restart apache2.service
Windows users see: http://php.net/manual/en/image.installation.php
Copy the file php_gd2.dll from your PHP's ext/ directory to where
you have your php extensions. (No need to copy if php_gd2.dll is in the extension
dir already. Look in php.ini for 'extension_dir' directive to
find what is your current extension directory)
Modify your php.ini and change the following line:
;extension=php_gd2.dll
to:
extension=php_gd2.dll
It seems that your GD library is not being used. Double check your php.ini file.
for any php version the command for ubuntu installation is
apt-get install php-gd
it will install the version that matches your php version, and it will be later updated with you php version.
I know this is an old thread but I've just recently came across this same Fatal error: Call to undefined function: imagecreate() issue while doing some QR coding using a fresh Xampp install on Windows.
I resolved the issue by first looking in the php.ini file for the GD extension and fixed the issue by uncommenting
;extension=gd
Afterwards QR code was generated to the browser as expected.
NOTE: Don't forget to restart Apache to make the change stick.
For Ubuntu 16.04:
sudo apt-get install php7.0-gd
Stop and then restart Apache Server.
PS: should first check your current php version
php -v
In My Case:
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019
10:00:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.3.5, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
So, my PHP version is 7.3, so, the command for my version is :
sudo apt-get install php7.3-gd
Update for PHP 7.4.0 >
You should not install any external libraries !
As stated in PHP docs:
As of PHP 7.4.0, --with-png-dir and --with-zlib-dir have been removed. libpng and zlib are required.
PHP 7.4.0 and newer versions comes bundled with libpng and zlib by default.
So all you merely need to do is to uncomment gd extension in php.ini file:
;extension=gd -> extension=gd
Problem solved :)
Dont forget restart apache or php-fpm if not running after installation

Categories