laravel artisan migrate give Mcrypto error in php 7.2 (CLI) - php

I have new in laravel I have set up laravel 5.5 in my system and its installed but when i start to use php artisan migrate its give error
Mcrypt PHP extension required
But when I run the phpinfo on browser there is mcrypt enable but its show the
PHP Version 7.1.12
But in terminal when I run the
php -v
its result
PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2-3+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I think Mycrypt not installed in the cli php
How can I fix it and make a laravel project
Thanks in advance

As it mentioned here: https://stackoverflow.com/a/37761637/8489245
You can try to install it with :
sudo apt-get update
sudo apt-get install mcrypt php7.2-mcrypt
sudo apt-get upgrade
if php7.2-mycrypt does not exist you can try to go back to version 7-0 of php and install it with :
sudo apt-get install mcrypt php7.0-mcrypt
Hope it help you!

mcrypt was deprecated in php7.1 and removed in 7.2.
From the release notes of Laravel 5.1:
In previous versions of Laravel, encryption was handled by the mcrypt PHP extension. However, beginning in Laravel 5.1, encryption is handled by the openssl extension, which is more actively maintained.
So you should be using openssl_encrypt, libsodium or another supported library.
Currently enabled modules:
$ php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

Related

PHP 7.2 and modules 'dom', 'mbstring', and 'simplexml'

I installed PHP 7.2 on my server and everything works fine except these three issues:
I face these problems:
The PHP extension dom is not loaded. Please contact your server
administrator or visit http://php.net/manual/en/dom.installation.php
for installation.
PHP extension mbstring is not loaded. Please contact your server
administrator or visit
http://php.net/manual/en/mbstring.installation.php for installation.
PHP extension simplexml is not loaded. Please contact your server
administrator or visit
http://php.net/manual/en/simplexml.installation.php for installation.
...
Now when I type php -m,
[root#localhost php.d]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]
[root#localhost php.d]#
It shows that there isn't any mbstring, dom or simplexml modules.
I've tried everything that I can find on google, but I can't seem to install those three modules.
php -v returns this:
PHP 7.2.7 (cli) (built: Jun 20 2018 08:21:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
What's wrong?
Try installing the missing modules as:
sudo yum install php7.2-dom
sudo yum install php7.2-mbstring
sudo yum install php7.2-simplexml
Don't forget to restart server after installation.
This may be weird, but once you install these (below commands) depending on your version (mine is 7.3 at the time of post), the modules get enabled somehow.
apt-get install php7.3
apt-get install php7.3-common
apt-get install php7.3-cli
service apache2 restart
php -m

PHP GD library is NOT installed but it has been enabled actually

I have PHP GD installed and enabled:
sudo gedit /etc/php/7.0/apache2/php.ini
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
But I cannot find it on the phpinfo(); screen, nor can I find it using the code below:
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "PHP GD library is installed on your web server";
}
else {
echo "PHP GD library is NOT installed on your web server";
}
Result: PHP GD library is NOT installed on your web server
I am on PHP 7.0:
$ php -v
PHP 7.0.22-0ubuntu0.17.04.1 (cli) (built: Aug 8 2017 22:03:30) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies
Any idea why and how I can fix it?
I am on Kubuntu 17.10 btw
If I go ahead installing it again:
$ sudo apt-get install php7.0-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php7.0-gd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'php7.0-gd' has no installation candidate
Why??
EDIT 1:
$ sudo apt-get install php-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-gd is already the newest version (1:7.1+54ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 86 not to upgrade.
EDIT 2:
But there is something strange - I am on PHP 7.0 but the GD below is php7.1-gd,
$ sudo apt-cache search php7-*
libapache2-mod-php7.1 - server-side, HTML-embedded scripting language (Apache 2 module)
php-all-dev - package depending on all supported PHP development packages
php7.1 - server-side, HTML-embedded scripting language (metapackage)
php7.1-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.1-cli - command-line interpreter for the PHP scripting language
php7.1-common - documentation, examples and common module for PHP
php7.1-curl - CURL module for PHP
php7.1-dev - Files for PHP7.1 module development
php7.1-gd - GD module for PHP
php7.1-gmp - GMP module for PHP
php7.1-json - JSON module for PHP
php7.1-ldap - LDAP module for PHP
php7.1-mysql - MySQL module for PHP
php7.1-odbc - ODBC module for PHP
php7.1-opcache - Zend OpCache module for PHP
php7.1-pgsql - PostgreSQL module for PHP
php7.1-pspell - pspell module for PHP
php7.1-readline - readline module for PHP
php7.1-recode - recode module for PHP
php7.1-snmp - SNMP module for PHP
php7.1-sqlite3 - SQLite3 module for PHP
php7.1-tidy - tidy module for PHP
php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.1-xmlrpc - XMLRPC-EPI module for PHP
libphp7.1-embed - HTML-embedded scripting language (Embedded SAPI library)
php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-ds - PHP extension providing efficient data structures for PHP 7
php-gearman - PHP wrapper to libgearman
php-geoip - GeoIP module for PHP
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-gnupg - PHP wrapper around the gpgme library
php-http - PECL HTTP module for PHP Extended HTTP Support
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-libsodium - PHP wrapper for the Sodium cryptographic library
php-mailparse - Email message manipulation for PHP
php-memcache - memcache extension module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-pinba - Pinba module for PHP
php-propro - propro module for PHP
php-ps - ps module for PHP
php-radius - radius client library for PHP
php-raphf - raphf module for PHP
php-redis - PHP extension for interfacing with Redis
php-remctl - PECL module for Kerberos-authenticated command execution
php-rrd - PHP bindings to rrd tool system
php-sass - PHP bindings to libsass - fast, native Sass parsing in PHP
php-smbclient - PHP wrapper for libsmbclient
php-solr - PHP extension for communicating with Apache Solr server
php-ssh2 - Bindings for the libssh2 library
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-symfony-polyfill-php70 - Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
php-tideways - Tideways PHP Profiler Extension
php-uploadprogress - file upload progress tracking extension for PHP
php-uuid - PHP UUID extension
php-xdebug - Xdebug Module for PHP
php-yac - YAC (Yet Another Cache) for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php-zmq - ZeroMQ messaging bindings for PHP
php7.1-bcmath - Bcmath module for PHP
php7.1-bz2 - bzip2 module for PHP
php7.1-dba - DBA module for PHP
php7.1-enchant - Enchant module for PHP
php7.1-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.1-imap - IMAP module for PHP
php7.1-interbase - Interbase module for PHP
php7.1-intl - Internationalisation module for PHP
php7.1-mapi - Complete and feature rich groupware solution - PHP MAPI bindings
php7.1-mbstring - MBSTRING module for PHP
php7.1-mcrypt - libmcrypt module for PHP
php7.1-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.1-soap - SOAP module for PHP
php7.1-sybase - Sybase module for PHP
php7.1-xsl - XSL module for PHP (dummy)
php7.1-zip - Zip module for PHP
php7cc - command line tool to detect PHP 7 incompatible code
php7.0-mysql - MySQL module for PHP
php7.0-readline - readline module for PHP
php7.0-opcache - Zend OpCache module for PHP
php7.0-mbstring - MBSTRING module for PHP
php7.0 - server-side, HTML-embedded scripting language (metapackage)
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
libapache2-mod-php7.0 - server-side, HTML-embedded scripting language (Apache 2 module)
php7.0-mcrypt - libmcrypt module for PHP
php7.0-curl - CURL module for PHP
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.0-xmlrpc - XMLRPC-EPI module for PHP
php7.0-json - JSON module for PHP
php7.0-common - documentation, examples and common module for PHP
php7.0-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
Is this causing the problem? Should I uninstall php7.1-gd?
I finally got it working following these 3 steps:
uninstalled PHP and all its libs from my machine following this answer.
upgraded Ubuntu to 18.04 following this guide.
installed PHP 7.2 following this guide.*
On my terminal:
$ sudo apt-get install php
$ sudo apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
$ php -v
PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May 9 2018 17:21:02) ( 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-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
$ sudo systemctl restart apache2
Result:
It took a few hours but worth it!

How to enable php5-redis using cli?

I have a docker container where I see all php modules:
root#7b995118fc27:~# php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
As we can see there is no php5-redis in that list.
When I try to install it I get a message saying it is already installed:
root#7b995118fc27:~# apt-get install php5-redis
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-redis is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
My php version is 5.6
root#7b995118fc27:~# php -v
PHP 5.6.31 (cli) (built: Sep 15 2017 01:12:36)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
So the only conclusion (if Im not wrong) is that the php5-redis is installed but not enabled.
This is what I have in the Dockerfile:
FROM php:5-apache
RUN a2enmod rewrite
RUN a2enmod expires
RUN service apache2 restart
RUN apachectl -M
RUN apt-get update
RUN apt-get install -y php5-redis
RUN apt-get install -y redis-server
RUN php -m
COPY src/ /var/www/html
EXPOSE 80
CMD ["redis-server"]
So, how can I enable php5-redis in this scenario?
You would need to add below statement to enable the redis extension
RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so

MongoClient on 32-bit Linux and PHP < 7 without refactoring

I have an error saying MongoClient class is not found.
I've tried both the instructions on the MongoDB website and these answers.
Upon php -v there is
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongo.so'
PHP 5.6.30-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
with sudo grep -rnw /etc -e "mongo.so"
I have
/etc/php/5.6/fpm/php.ini:2033:extension=mongo.so
/etc/php/5.6/cli/php.ini:2032:extension=mongo.so
/etc/php/5.6/apache2/php.ini:2033:extension=mongo.so
Then I tried the manual installation.
When I run phpize
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
At the make test output I get
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
How do I compile the correct module?
I've removed php 7 entirely
sudo apt-get purge php7.*
I guess you had installed the wrong extension for your system.
I suggest to start fresh and use pecl to install and compile mongo extension properly.
Install pecl (assuming that you are using Debian-based distribution with correct apt repos, pecl comes bundled with php-pear)
sudo apt-get install php5-dev php-pear
Install the legacy mongo driver from pecl
sudo pecl install mongo
Add extension=mongo.so on php.ini
sudo su
echo "extension=mongo.so" >> /etc/php5/mods-available/mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/30-mongo.ini
Note that the legacy driver is not compatible with PHP 7+ and the lastest version of MongoDB one can use with this driver is 3.0. See the compatibility chart from MongoDB Docs.

PHP 5.3 seems to be missing Intl extension by default

My system is Ubuntu 12.04, PHP 5.3, and I'm trying to run some basic Intl code like this:
<?php
$coll = collator_create('en_US');
$result = collator_compare($coll, "string#1", "string#2");
and it outputs
PHP Fatal error: Call to undefined function collator_create()
Wasn't Intl extension supposed to be bundled with PHP since version 5.3?
PHP was installed via apt-get with this command line (I don't use Apache):
apt-get install php5 php5-cli php5-mysql php5-cgi php5-fpm php5-curl php-apc php5-memcache php5-memcached php5-common php5-gd php-xml-parser php-pear php5-imap php5-mcrypt php5-xdebug php5-suhosin
And here is what php -v produces:
PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH
You have specify --enable-intl when installing to use the bundled version of intl, or you can install it via PECL. See: http://www.php.net/manual/en/intl.installation.php
apt-get install php5-intl will also work.
Add php5-intl to the list of things you install.
It looks like it's just not part of the core PHP5 release, even though it is an option to be included, similar to how php-apc is now a standard part of PHP, though you have to explicitly install it.
Try in php.ini uncomment extension intl "extension = php_intl.dll", should be removed ";" before "extension", and then restart the server.

Categories