How can I add php extension mcrypt to Laravel/Homestead? - php

I have set up laravel/homestead, now when I use composer install on a project, I get the error message:
The requested PHP extension mcrypt is missing from your system
(I know I shouldn't use mcrypt anymore, but the project was handed over to me so I cant change this for now)
I m using PHP 7.1 (where mcrypt is marked deprecated I think but still usable if I activate it?)
php -v shows "7.1.30"
I added extension=php_mcrypt.dll into my php.ini and then restarted homestead (halt & up again) I can see the line in the php.ini now but php -m does not show mcrypt... and composer install still fails.
How can I activate mcrypt in homestead?

MCrypt was removed from PHP7 for one of the main reasons why you want to upgrade PHP: Security. The MCrypt library is not maintained anymore. There is no way to fix it on Windows, it's simply not there anymore. You need to change the code or downgrade (not recommended!!!).

Related

Error installing silverstripe on MAMP 5.1 on 2016 macbook [duplicate]

I've been trying to install Magento 2. I did load everything and with the last commands "composer update" or "composer install" I'm having problem.
Problem 1
- The requested PHP extension ext-mcrypt * is missing from your system.
Problem 2
- The requested PHP extension ext-intl * is missing from your system.
The thing is I'm not a pro Mac user or anything so it's very complicated for me to understand what I need to do to resolve this.
I saw a topic here at stackoverflow with the same problem but in that case they were using MAMP. I'm using XAMPP. They were telling to override PHP with MAMP's PHP with the .bash_profile file. I tried the same - didn't quite understand what I was doing.
So please, can anyone help me with solving ext-mcrypt and ext-intl stuff? I don't even know how to find out if they are missin or not.
Thanks!
Here's what in place of mcrypt
[mcrypt]
; For more information about mcrypt settings see http://php.net/mcrypt-module-open
; Directory where to load mcrypt algorithms
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.algorithms_dir=
; Directory where to load mcrypt modes
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.modes_dir=
FINAL NOTES:
I marked answer as correct as it resolved my issue with mcrypt with the link from Laravel requires the Mcrypt PHP extension next I had issue with ext-intl and to resolve this please follow these links: http://codingexplained.com/operating-systems/mac/installing-php-intl-extension-os-x-mavericks and Php-intl installation on XAMPP
I did write an article about these issues and solution. hopefully this helps too!
Have a look at this answer Laravel requires the Mcrypt PHP extension and the following one.
If mcrypt is not enabled open your php.ini (see my first answer link above how to find it) and search for
;extension=php_mcrypt.so
then remove the ; from the beginning of that line. Same procedure for the other extension.
On linux I:
sudo apt-get install php7.0-mcrypt ;
sudo apt-get install php7.0-intl
Following things you can check -
Apache Version: 2.2 or 2.4 and Enable: mod_rewrite.mod_rewrite enables the server to perform URL rewriting.
PHP: 5.4.x where x = 11 or later 5.5.x and
Enable PHP Extension: PDO/MySQL,mbstring, mcrypt, mhash, simplexml, curl, gd2, ImageMagick 6.3.7 (or later) or both soap and
add xdebug.max_nesting_level=50000; at php.ini
MySQL Version : 5.6.x and upper
For more info please have a look at this URL -
http://magentostriker.blogspot.in/2015/03/magento-2-installation.html
Hope it will help.
If you are using Linux and PHP 7.0 you would use something like this:
yum install php70u-intl
I have PHP version 70u in the above example. Bu this will provide "ext-intl".

Using libsodium in PHP 7.2

In PHP 7.2 libsodium should be part of PHP core. Is any entry in php.ini file required to make it work or maybe it should work out of the box?
I'm trying with PHP Version 7.2.0beta2 and functions like sodium_version_string() or sodium_compare are unknown. I'm using PHP docker box (7.2-rc-fpm)
Just in case - I haven't installed any PECL extension because as far as I understand it shouldn't be necessary.
In order for this extension to be built, the library has to be present, as long as the development headers.
In addition, the --with-sodium option has to be given to the ./configure script before compiling PHP.
If you don't want to recompile PHP, you can install the PECL version, which offers the exact same API (I usually update the PECL version first, and then port the changes to the PHP source code).

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

Mailparse and PHP 5.6.2?

Is there a version of Mailparse that works with PHP 5.6.2? I installed it this morning using pecl install mailparse and it placed mailparse.so in what seems to be the wrong location and when I view it in Finder it shows up as a document.
I decided for the heck of it to copy it to the appropriate folder and when I execute the code the uses it I get these messages:
Warning: PHP Startup: mailparse: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
FYI, I'm not a PHP expert by any stretch.
For php 5.6 and debian first install php5-dev module:
apt-get install php5-dev
and next use latest build for php5, which is currently:
pecl install mailparse-2.1.6
If mailparse is already installed you can remove it before any action:
pecl uninstall mailparse-2.1.6
Officially, no, there's not.
http://php.net/manual/en/mailparse.installation.php
Windows users will enable php_mailparse.dll inside of php.ini in order
to use these functions. A DLL for this PECL extension is currently
unavailable. See also the building on Windows section.
It seems to be just a matter of compiling, so anyone should be able to compile it and share the DLL, but as far as I know no one has done this.
mailparse hasn't had a release for some years - though the git repo is showing recent work (April 2015). I recently used it for a project, however the version I used had some issues in decoding the display-name & email from a list of not perfectly formatted string of multiple names.
I've since installed mmucklo/email-parse and I'm using that as a native PHP solution on PHP 5.6.

Intl PHP extension not working

I want to use https://github.com/juriansluiman/SlmLocale module in zend framework-2 and need intl extension, I have installed using pecl and it show success. I had added
extension=intl.so
and restarted my MAMP-Pro, I had tried other links as well:
http://mynameispagewood.com/web-development/how-to-enable-intl-extension-mamp-osx-10-9-2/
http://codingexplained.com/operating-systems/mac/installing-php-intl-extension-os-x-mavericks
to enable it but its not working.
note: No error while starting apache
Is their any alternate method to enable it?
Any light on the path would be helpful
Thanks
You will need to ensure that the version of php being called is in the install path for Brew, otherwise it will be picking up the native installed php
The problem can be solved by first checking the php version in the terminal.
The which php command will print the /Applications/MAMP/bin/php/php7.1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.
and then check
echo $PATH
/Applications/MAMP/bin/php/php7.1.8/bin/php
If this is right, then no need of installing intl extension, restart MAMP PRO, then it should work.

Categories