Error installing Laravel 4 with composer - php

When I try to install Laravel 4 via Composer, I get the following message in Terminal
Mcrypt PHP extension required. Script php artisan optimize handling
the post-install-cmd event returned with an error
The PHP version on my computer is 5.5.3 and when I run phpinfo it shows that mcrypt is enabled. When I run the which php command in Terminal it shows
/usr/bin/php
I therefore extended the $PATH with .bash_profile.
export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH
Unfortunately, the which php command still shows /usr/bin/php after extending $PATH. And as a result the error is still there.
So I am out of ideas on how to solve this issue. Does anyone have an idea? Thanks!

There is difference between the MAMP PHP version and you "Terminal" PHP version. Therefore are you probably setting up the export path.
When you are changing the export path you have to restart your terminal before it will take effect on your computer.
I am not sure of this but when your error is appearing and older version of Laravel will be installed.
What do you get when you execute: php -v in your terminal?

Related

Enabling CURL for Codeception

I have an issue when executing tests with Codeception on Ubuntu 18.04 LTS. When I execute a test I get an error saying that CURL extension is not installed, but it is.
This is the error message I get:
Codeception requires CURL extension installed to make tests run
If you are not sure, how to install CURL, please refer to
StackOverflow
Notice: PHP for Apache/Nginx and CLI can have different php.ini
files.
Please make sure that your PHP you run from console has CURL enabled.
I enabled curl extension in php.ini file, but the result stays the same.
I'll be grateful for any help with this issue.
I guess, that you are using more then one PHP Version on the same system.
Try in command line php -m |grep curl. When the output is empty the current php has no curl extension installed. If the output is "curl", then it is and you can call codeception with php infront so you can be sure the php in the path is used.
php codecept run
And please be sure be up-to-date for codeception version.

laravel 4 artisan make command - error Mcrypt PHP extension required

I'm trying to glean a signal from the noise in debugging this.
When I run ./artisan make:middleware MyTools, I get:
Mcrypt PHP extension required
Solutions seem to revolve around setting a proper value in /etc/php5/mods-available/mcrypt.ini and then doing a php5enmod mcrypt and Apache restart. Sounds good, and a phpinfo() call shows it's there and that I'm running PHP 5.5.9-1ubuntu4.20. All peachy.
However, I'm not running php 5 on the command line for artisan! Typing php -v tells me I'm running php 7.0.14-2.
When I go to /etc/php/7.0/mods-available, indeed I do not see mcrypt.ini - my question is how to "get" a proper mycrypt.ini file in there, have Mcrypt running for the COMMAND LINE, and not have to change anything else - for example I want to leave the webserver as it is at 5.5.9. How do I do this?
-- UPDATE --
See the discussion/comments below, I was able to get around this by DOWNGRADING my CLI to 5.5.9 vs. installing mcrypt into php7. This is not likely the best solution and I welcome a better one.

I'm getting php5.5 instead php7 when I run exec(php -v) in php script

When I run php -v in cli I get the exact php version 7, but when i run exec("php -v") in web server I get php 5.5 even thought in phpinfo i see that I am runing php 7?! Any idea why I get the older version of PHP?
running exec you get the CLI version of PHP
you probably installed php5.5 as CLI and php7 as apache module
If you use CentOs, add this line at the end of /etc/bashrc (or ~/.profile for Ubuntu)
export PATH=$PATH:/your/path/to/php7/bin
Then run:
source /etc/bashrc
P/s It may be better if you edit /etc/profile.d. Take a look both of them.
UPDATE
In MacOS, let edit ~/.bash_profile (create it if it does not exist) with the same content.

ImageMagick works in command line but when exec() in php it returns 5 with "incompatible library version"

I'm having a bizarre problem with php 5.3.6 and ImageMagick (command line) using MAMP (and Macports too..I tried both) on OS X.
When I run the identify command from the CLI, it works fine. But when I run the exact same command using exec(), it returns a value code of 5 and in the apache error logs I have:
dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib
Referenced from: /opt/local/bin/identify Reason: Incompatible
library version: identify requires version 14.0.0 or later, but
libfreetype.6.dylib provides version 13.0.0
E.g.
The cli command is:
/opt/local/bin/identify /Users/leonardteo/Documents/1.jpg
This works just fine when executed from the command line. When executed from PHP:
exec("/opt/local/bin/identify /Users/leonardteo/Documents/1.jpg", $output, $return);
$return is 5
$output is nothing
Checking the apache logs gives the above issue with libfreetype.
I installed ImageMagick using Macports. I've also tried a manual build from source and running identify from /usr/local/bin/identify and I get the same result. I have also tried running PHP from Macports instead of MAMP and I get the same result.
Could someone please help shed light on this?
Edit this file:
/Applications/MAMP/Library/bin/envvars
Comment out the following lines:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

php related error in linux terminal while setting up symfony framework

i am trying to setup a new symfony framework project on ubuntu by following the documentation. But all the commands mentioned in the docs starting with 'php' give out the following error.
The program 'php' is currently not installed. You can install it by typing:
sudo apt-get install php5-cli
bash: php: command not found.
But php is installed and running on the system! How do i get past this error ?
Thanks in advance.
There are several different PHP packages; probably the one that is installed is the PHP module for Apache, not the command-line (CLI) version invoked as php.
Just run the command like it says, and you should be fine.
Is php on your path? (does it start if you just type in 'php' at the prompt or do you need to specify a path?)
If so, then its possible that the path is hardcoded to look elsewhere for your PHP executable. Try grepping the scripts to see where its looking.
If php is NOT on your path then try adding it, e.g. if php is in /usr/local/bin (and /usr/local/bin is not currently on your path)
export PATH=$PATH:/usr/local/bin
HTH
C.

Categories