Enable MCrypt using MAMP - php

I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:
php -m | grep mcrypt
output: mcrypt
I can locate the library but it doesn't seem to be enabled.

That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.
Although it may just be enabled for CLI.
You can try editing the PHP.ini file and adding the following line under the ; Extensions section:
extension=mcrypt.so
Restart Apache / MAMP after saving php.ini file.
To find the correct php.ini file to edit, run the following command line:
php --info | grep php.ini
(If the line already exists, you may just need to remove the ; thats in front of it.)

I have tried so many ways but had no luck.
After a lot of trials finally came up with a solution.
Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin
It might be different in your case. Now run the below command with sudo
sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1
Now You should add extension=mcrypt.so to php.ini
Restart MAMP Service and check if it is working.

I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...
The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.
The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)
Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line
Added to .bash_profile
alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'

try in console
pecl install mcrypt

Using Brew:
Install mcrypt: brew install mcrypt
In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):
extension=mcrypt.so
Save, restart and test (with php -i | grep mcrypt for example)

Related

Magento PHP Extension intl - XAMPP

I tried to install Magento on localhost (XAMPP) for the first time today. As Magento installer does the Readiness Check an error occurs, as it is missing PHP Extension intl. I have done research, but all I can find is to remove ; from ";extension=php_intl.dll" in php.ini in etc folder. This does not work (tried to restart XAMPP and the computer several times)
This is driving me crazy, please help.
I am on macOS Sierra.
First of all, you should check with phpinfo() method to check intl loaded or not. some time may this loaded bud you are in the mistakes.
after that, check php_intl.dll existin this folder : "\xampp\php\ext"
if all of these are ok, you may check log files.
UPDATE:
Base on your update about OS,if you have homebrew available and have PHP7:
$ brew install php70-intl // For PHP7.0
$ brew install php71-intl // For PHP7.1
For PHP5.5:
$ brew install php55-intl
Re-open your terminal window to ensure it works right in your session. To see if it loaded via your CLI interpreter:
$ php -m | grep intl
Or:
$ php -i "(command-line 'phpinfo()')" | grep intl
Source: https://daveismyname.blog/blog/install-php-intl-on-mac-using-homebrew
You need to check your correct php.ini file and also create a php file with a function phpinfo() and run this file and check the extension that are not installed.
To enable/installed these extension go to php.ini file and uncomment those extension.
save this file and restart the apache/xampp
I hope it will work for you.

Xdebug on macOS 10.13 with PHP 7

So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();
My php.ini is definitely being loaded:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Here's what my /etc/php.ini looks like where I configure Xdebug:
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
[Update, fixed that typo here...]
However, Xdebug doesn't load and checking php -i give no results:
$php -i | grep xdebug
PHP Warning: Method xdebug_start_function_monitor() cannot be a NULL
function in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
Segmentation fault: 11
And yes, the path to the file is correct:
$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*
This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.
When I check my apache log I get the following error:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Expected in: flat namespace
in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
I'm not making progress in terms of find out how I can resolve this error:
Symbol not found: _xdebug_monitored_function_dtor
Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.
So I downloaded the latest source from the xdebug website and did the following:
Installed autoconf with brew;
Run phpize to configure the build for the new Zend engine;
Run ./configure
Run make
Now the new binary is under modules/xdebug.so
However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.
Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!
In order to install it you have to have xcode command line tools.
So you need to run:
xcode-select --install
Then you need to install autoconf:
brew install autoconf
Then you have to download the code from here.
After that you have to run in the folder of the source code:
phpize
./configure
make
sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)
And finally inside php.ini add
zend_extension=/usr/local/php/extensions/xdebug.so
After that you can enable xdebug inside php.ini and restart apache
sudo apachectl restart
you made a typo in "zend_extention". this should be zend_extension.
and i think the full path is unnecessary
zend_extension=xdebug.so
should be enough
If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew brew install autoconf.
Change to the PHP version that you want Xdebug on, run brew unlink php#7.1 && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
Run phpize to configure the build for the new Zend engine.
Run ./configure.
Run make.
Xdebug extension xdebug.so gets compiled in modules directory.
Create a new directory path under /usr/local/lib/php/7.3.1/extensions/ and copy xdebug.so to this location. Here, 7.3.1 is the current version that I switched earlier, change this to match your PHP version.
Open php.ini in an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so" then save the change.
Run php -v and it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.
For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6
Hello for everyone that got error trying to install xDebug on Mac.
error: unknown type name 'uint64_t'
There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.
https://github.com/cython/cython/issues/2009

different versions of php being used

I am trying to install magento and it keeps throwing the error "PHP extension mcrypt must be loaded". When I tried to install mcrypt I got a message that it is already installed.
So I ran php -v, which php and php -i | grep mcrypt in the command line and got back
PHP 5.4.23 (cli)....
and
/usr/local/bin/php
and
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
So I added phpinfo(); die(); to my index.php magento file and that returned
Version 5.4.17
Configuration File (php.ini) Path /etc
Loaded Configuration File /etc/php.ini
but no reference to mcrypt
Am I right in reading that as magento is using a different version of php to what the commandline is? and if so how do I resolve this situation?
I am running other installs of Magento and so when I considered trying to delete /etc and letting Magento automatically pick up the correct version, I decided against it as I don't want the other installs to stop working.
You are right when you say that magento is using different php version (altough only subversion). It is most likely that your cli .ini is different from apache .ini
What you can try is add extension=mcrypt.so to /etc/php.ini and restart apache
Echo your phpinfo(). Via cmd it's possible to receive other information then needed. You'll see which PHP version is used and where your php.ini is located.
Open php.ini and search for ;php_mcrypt.dll. Remove the semicolon and restart Apache.
Edit: for Linux versions:
apt-get install php5-mcrypt
service apache2 restart - restart Apache
If you get the 'already installed' message you could use:
apt-get --reinstall install php5-mcrypt
Make sure that the semicolon is remove in php.ini: extension=mcrypt.so

Symfony 2: Install and enable the intl extension

I'm using XAMPP for Windows and decided to try out Symfony 2.
As soon as I get to Symfony Configuration page it recommends me to install and enable intl.
I tried reading PEAR's and PECL's guides, since I'm total 0 on this topic(started learning PHP recently), but nothing worked.
I found php_intl.dll inside my C:\xamp\php\ext. The php.ini's extension_dir= is set to "C:\xampp\php\ext". I was only missing the extension=php_intl.dll inside php.ini, so I added it.
Unfortunately it didn't work, and Symfony keeps asking me for intl.
Whenever you make changes to php.ini, remember to restart Apache. Otherwise the changes won't take effect. You can do this in the XAMPP Control Panel by clicking the stop/start button in the Apache module row.
http://php.net/manual/en/intl.requirements.php
This extension is bundled with PHP as of PHP version 5.3.0.
Alternatively, the PECL version of this extension may be used with all
PHP versions greater than 5.2.0 (5.2.4+ recommended).
also read my comment to your post above
Follow these steps:
Copy all the file names starting with "icu" from C:\wamp\bin\php\php5.5.12 and paste to C:\wamp\bin\apache\apache2.4.9\bin (I am using WAMP. Figure it out yourself for XAMP.)
You can try. Nothing will harm. If you feel the things are not working, you can delete them. I am sure it will work for you 100%.
Uncomment the following line on C:\wamp\bin\apache\apache2.4.9\bin\php.ini
extension=php_intl.dll
It will work.
For Linux users:
Installing php5-intl made it work for me
sudo apt-get install php5-intl
found here:
http://www.php.net/manual/en/intl.setup.php
For OS X users:
1.Normally, the PHP is automatically installed on OSX. So, if you would like to use the XAMPP, or whatever apache server, you must change the path point to XAMPP. You can check the path by using:
$ which php
(do not copy $ sign, it means than you should type this in Terminal, not php)
You should get: /Applications/XAMPP/xamppfiles/bin/php ,
if not, you will get /usr/bin/php.
This is OSX' php. So, you have to change it to XAMPP' php by using:
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
2.Run this command to download, unpack, compile and install ICU (you can choose different version is your Symfony required):
$ curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz && tar -zxf /tmp/icu.tar.gz -C /tmp && cd /tmp/icu/source && ./configure --prefix=/usr/local && make && sudo make install
than run:
$ sudo pecl install intl
and specify where ICU libraries and headers can be found [DEFAULT] :
/usr/local
Pay attention to information in install report:
You should add "extension=intl.so" to php.ini
Don't forget to reboot Apache and check version:
<?php
if (extension_loaded('intl')) {
echo "PHP: " . PHP_VERSION . "<br>\n";
echo "ICU: " . INTL_ICU_VERSION . "<br>\n";
} else {
die('OOPS! The intl extension is not enabled!');
}
Partially taken from here but modified to get success Install PHP Internationalization extension (Intl) on XAMPP on Mac
To activate this extension in Xampp, just edit your php.ini (i.e. in C:\xampp\php directory) and remove the semicolon to uncomment this line :
;extension=php_intl.dll
Eventually don’t forget to restart Apache !
To solve this go to "c:\xampp\php\php.ini" open it in your editor and search for Dynamic Extensions then go down search for ;extension=php_intl.dll and enable it(remove ; to became like ) extension=php_intl.dll after that save your file php.ini and restart your localhost

Install Tidy, PHP

I guess when php was installed on my box --with-tidy arg was not included.
When browsing my php.ini the line:
;extension=php_tidy.dll
is missing.
How can I add the module to my php install? Note I tried adding:
extension=php_tidy.dll
but with no luck.
I checked the docs but all they say is:
This extension is bundled with PHP 5 and greater, and is installed using the --with-tidy configure option.
On Ubuntu, you can add tidy to your php5 installation by running this command in a terminal:
$ sudo apt-get install php5-tidy
If you want to check if it is already installed or validate that the command above worked:
$ php -i | grep libTidy
libTidy Release => 25 March 2009 // means tidy is installed
To install both php5 and tidy at the same time, use this command (as an alternative to the "--with-tidy" configuration option):
$ sudo apt-get install php5 php5-tidy
For PHP 7 just run
sudo apt-get install php-tidy
And restart Apache, That's it :)
Update: Thanks to #Arnis Juraga
For the version above PHP 7, you can mention the version code as follows.
apt-get install php7.4-tidy
I was having the same trouble, and wrote up my solution here:
Installing Tidy 2.0 PHP extension on Ubuntu 10.10
http://web.onassar.com/blog/2010/11/16/installing-tidy-2-0-php-extension-on-ubuntu-10-10/
It works on newer versions of Ubuntu as well.
While it may not be the most direct route, it works well.
I hope it helps others.
Put that line in php.ini next to the other extension=...dll lines and make sure php_tidy.dll is in the directory configured in php.ini under extension_dir.
In ubuntu: you need to run the following command in terminal
sudo apt-get install php5-tidy
and the restart the server
sudo service apache2 restart.
For those who are having trouble enabling Tidy extension for PHP (using PHP handler for Apache server) on Windows (WAMP server), please note that you may be editing the wrong php.ini file. Assuming that WAMP server is installed in C:\wamp[ver]\ where [ver] is a variable version number.
File that you're probably editing:
C:\wamp[ver]\bin\php\php[ver]\php.ini
File that you must edit:
C:\wamp[ver]\bin\apache\apache[ver]\bin\php.ini
You also might want to make sure what's the correct php.ini file to edit by creating an info php file and add this code to it:
<?php phpinfo();
Then look for Loaded Configuration File string.
Finally make sure you uncomment this line within the correct php.ini file:
extension=tidy

Categories