Mcrypt PHP extension installation doesn't work - laravel

I am trying to install laravel via composer ( http://laravel.com/docs/quick#installation ) and I got stuck at the point where it requires Mcrypt extension
Mcrypt PHP extension required.
I installed Mcrypt extension using brew. But still it throws the same requirement error.
I also tried changing the path as suggested here but my which php doesn't show anything other than
/usr/bin/php
Am I doing something wrong with assigning path at ~/.bash_profile? why is "which php" output still the same. and why is mcrypt installation not working on laravel workout?

What command did you use to install mcrypt? It is possible that you try to install the mcrypt extension for the wrong php version.
Try debugging the situation with
php -v
and
ls -al /usr/bin/php
There is a different install recipe for version 5.5 and 5.4 of PHP.
brew install php54-mcrypt
brew install php55-mcrypt

OK, I was fed up off all other solutions which weren't working, so finally downloading and compiling php from source itself worked.
So here's what I did:
Download php from official site
Follow following instructions
cd to/extracted/php/folder
cd /ext/mycript
phpize
./configure
make
make test
sudo make install
Add extension=mcrypt.so to /etc/php.ini file.
Now restart the server
sudo apachectl restart
You are good to go, Cheers! :)

Related

Unable to install composer globally on Mac OS Catalina

I want to install composer for laravel development on my latest version of mac OS. I followed all the step by step instructions to install composer on the website and it installed composer.phar. So I have to move to /usr/local/bin/composer for it to work.
I ran the usual command:
mv composer.phar /usr/local/bin/composer
and it gave an error saying /usr/local/bin/composer: No such file or directory
I even added a sudo command in front to see if it works and received the same error. I looked up other solution telling me to make a new directory there, but it wouldn't let me do so and gave me a permission denied error.
You should create the directory manually before proceeding:
sudo mkdir -p /usr/local/bin
then
sudo mv composer.phar /usr/local/bin/composer
For solving your second problem
It needs zip extension,
Check your PHP version first
php -v
If for instance PHP version is 7.2, then try below command (use your PHP version)
brew update
brew install php#7.2
brew link php#7.2

Composer error after installing

sS https://getcomposer.org/installer | php
from the terminal. I got this output:
Composer successfully installed to: /Users/kevin/composer.phar
Use it: php composer.phar
Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:
The OpenSSL library (0.9.8zc) used by PHP does not support TLSv1.2 or TLSv1.1.
If possible you should upgrade OpenSSL to version 1.0.1 or above.
Then I tried running: composer -h
And it didn't work, it said command not found. Any ideas on how to solve this?
Would be appreciated.
Thanks in advance,
Kevin
As the script said, composer is installed to /Users/kevin/composer.phar, which means it is only available when you are in this directory. In order to make it available everywhere, the file has to be placed inside the /usr/local/bin folder.
The following command will install it there directly:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Issues installing composer correctly on OS X El Capitan

I know there are some questions about how to install composer on SO, but they did not help me.
I am trying to install composer (for laravel). I have OS X El Capitan.
I downloaded composer like this:
$ curl -sS https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /Users/blckbird/composer.phar
Use it: php composer.par
Next, I tried to execute the laravel installation:
composer global require "laravel/installer"
Which did not work because:
-bash: composer: command not found
So I tried:
sudo mv composer.phar /usr/local/composer
Which worked, however, I still can not execute composer (same error as above).
What am I doing wrong and how can I install composer correct?
Since your composer.phar is installed in /Users/blckbird/, try this for global installation:
sudo mv /Users/blckbird/composer.phar /usr/local/bin/composer
Note: On some versions of OSX the /usr directory does not exist by default. If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding: mkdir -p /usr/local/bin. More info.

How to setup XDebug for PHP7 on Mac?

I've installed PHP 7 on my mac using Homebrew i.e.
$ brew install php70
Also I want to have the the XDebug setup on my machine.
Ideally I would love to have an easy solution like using brew again, but unfortunately it seems there is no such formula exist (at least yet), and the latest package is homebrew/php/php56-xdebug.
I thought before start the manual installation, check here to see if there are any other workaround.
Any advice will be greatly appreciated.
First, make sure you're on the version of PHP for which you want Xdebug installed. It needs to be installed separately for each major version (7.0 vs 7.1 vs 7.2). You can check your version using php -v.
Then, run pecl install xdebug.
Once it's finished installing, you'll see a message like this:
Installing '/usr/local/Cellar/php/7.2.8/pecl/20170718/xdebug.so'
Then go to your php.ini (which you can find by running php --ini, and add these two lines to it:
zend_extension="/usr/local/Cellar/php/7.2.8/pecl/20170718/xdebug.so"
xdebug.remote_enable=on
Obviously, change the path to whatever was printed by the pecl xdebug installation.
It is available in Homebrew now as homebrew/php/php71-xdebug.
Try:
brew install php71-xdebug
and if that doesn't work:
brew install --build-from-source php71-xdebug
Source: xdebug install on php70
As stated by Homebrew, Homebrew/php tag was deprecated.
So it's not possible to install xdebug through Homebrew anymore. Please use PECL instead: https://xdebug.org/docs/install#pecl
Since Brew is no longer working, you can use pecl to install the debugger.
It's not as good as brew, you may run into dependency problems but it works. Install php with brew, whatever version you want, then use pecl.
brew install php
pecl install xdebug
Xdebug 2.4.0beta1 already supports PHP 7. Unfortunately the only way for installation for now is to compile it from the source code.
If brew install php71-xdebug is not working, and it returns this error:
Error: No available formula with the name "php71-xdebug"
Try run this command first: brew tap homebrew/php .

Mcrypt PHP extension required on Mac OS X

I keep getting this error
Mcrypt PHP extension required
at the bottom after I run a composer update :
Since I am using Mac, I have tried running :
brew search mcrypt
brew install php56-mcrypt
I still get the same error message.
Steps
I solved this by running the following commands
brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54-mcrypt
php --version // To Test your php
sudo composer update
Result
No more Mcrypt warning !!
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Generating optimized class loader
After update brew:
brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
If you have installed php5.6 (or higher), you can use the following command to find out what versions are available in brew:
$ brew search mcrypt
homebrew/php/php53-mcrypt homebrew/php/php55-mcrypt homebrew/php/php70-mcrypt mcrypt
homebrew/php/php54-mcrypt homebrew/php/php56-mcrypt homebrew/php/php71-mcrypt
In my case, I am using php7.0:
$ brew install php70-mcrypt
On macOS High Sierra I did this steps:
1- Search the package:
brew search mcrypt
Result:
==> Searching local taps... homebrew/php/php71-mcrypt mcrypt homebrew/php/php53-mcrypt
homebrew/php/php54-mcrypt homebrew/php/php55-mcrypt
homebrew/php/php56-mcrypt homebrew/php/php70-mcrypt
libtomcrypt
2- Search my php version to know what can I need to install:
php --version
Result:
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS ) Copyright (c)
1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017
Zend Technologies
3- Install the correct package, for me was 7.1.7 => homebrew/php/php71-mcrypt
brew install homebrew/php/php71-mcrypt
4- Find the find "mcrypt.so" extension file
find /usr/ -type f -name "mcrypt.so"
Result:
find:
/usr//local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so
5- Search the php.ini
php -i | grep 'Configuration File'
Result (if exist):
Configuration File (php.ini) Path => /etc Loaded Configuration File =>
/etc/php.ini
6- Add the next line at the end on /etc/php.ini (see the last step your correct path) the extension mcrypt.so
extension=/usr/local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so
Finish, you can now execute your command.
You'll need to add the line
extension=mcrypt.so
In your phi.ini file responsible for the CLI PHP version.
To find where it is, run:
php -i | grep 'Configuration File'
In use XAMPP on my Mac, so I had to install php and then compile mcrypt using pecl, after that I copied mcrypt.so to XAMPP.
The actual list of available releases is: http://pecl.php.net/package/mcrypt
The commands was:
echo Install php...
brew install php
/usr/local/opt/php/bin/php -v
echo Correction of "error Connection to `ssl://pecl.php.net:443' failed"...
wget http://curl.haxx.se/ca/cacert.pem
sudo cp cacert.pem /private/etc/ssl/cert.pem
sudo mv cacert.pem /Applications/XAMPP/xamppfiles/share/openssl/cert.pem
/usr/local/opt/php/bin/pecl list-all
echo Compile and Install mcrypt.so...
sudo /usr/local/opt/php/bin/pecl install mcrypt-1.0.1
The last message of build process of pecl was:
Build process completed successfully
Installing '/usr/local/Cellar/php/7.2.7/pecl/20170718/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.1
Extension mcrypt enabled in php.ini
Based on path of build process I copied the compiled mcrypt.so to XAMPP and enable the extension on php.ini:
sudo cp /usr/local/Cellar/php/7.2.7/pecl/20170718/mcrypt.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20170718/mcrypt.so
echo 'extension=mcrypt.so' >> /Applications/XAMPP/xamppfiles/etc/php.ini
Check if it works:
/Applications/XAMPP/bin/php -i | grep "mcrypt"
The result have to be:
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
Remember to restart Apache to see it working using browser.
Maybe it helps someone and I win one thumbs up. Thanks
if you using brew try this :
1.Unistall existing php then Install shivammathur/php
add shivammathur php
brew tap shivammathur/php
change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)
brew install shivammathur/php/php#8.1
2.Install shivammathur/extensions it s will add extension to php
then
brew tap shivammathur/extensions
brew install shivammathur/extensions/mcrypt#8.1
then you install mcrypt with same version as php version
brew install mcrypt#8.1
then restart httpd
brew services restart httpd
Ref :
https://github.com/shivammathur/homebrew-php
https://github.com/shivammathur/homebrew-extensions

Resources