Why is my php -v version different from phpinfo()? - php

I looked at some of the similar questions and they have a similar problem except their php -v version is the one that is higher than the phpinfo() reported version. For when I call phpinfo() from php file it shows 5.5.25 which is correct. In the terminal through ssh I run php -v and it gives me 5.4.43. I'm using GoDaddy hosting and on cPanel I have it set to 5.5. I'm using Composer and Laravel. When I create a new Laravel project it gives me this error:
[~/public_html]$ laravel new blog
Crafting application...
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
run-script [--dev] [--no-dev] [-l|--list] [script] [args1] ... [argsN]
Application ready! Build something amazing.

You need to use a different path to get to the right version of the command line PHP.
Use
which -a php
To get the paths to the available versions of PHP, then use the full pathname.
For example
/usr/bin/php5

Related

Symfony can not find config_.yml

I have a symfony project of which I can't clear the cache of all of a sudden. I only made some changes to twig. I always clean the cache with the following command.
php bin/console cache:clear --no-warmup -e
After executing the command I get the following message:
The file "C:\xampp\htdocs\postcodezoeker\app/config/config_.yml" does not exist.
After searching on Google I found some other post on Stackoverflow. They pointed out to use the following command which executes with no errors.
php bin/console cache:clear --env=prod
But when I go to webpage I get the following error:
Fatal error: Cannot redeclare class Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser in C:\xampp\htdocs\postcodezoeker\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser.php on line 24
I created a clean new project and tried to execute the commands and still got the same thing. Reinstalling XAMPP did not do the trick and a newer version of symfony neither.
I hope you guys can help me out. I use PHP version 5.6.15 and Symfony 3.4
The call you are using does not provide any information about the environment:
php bin/console cache:clear --no-warmup -e
...forces Symfony to run using the environment (empty string). The service configuration is read from the file config_.yml afterwards, which (according to that error message) does not exist.
Either provide a value for the environment (for example using -e prod) or don't use -e after all.

PhpStorm + XAMPP not showing latest PHP version in command line

I am using OSX running on El Capitan and setting up PhpStorm and the Laravel environment has been a nightmare. I created a project setting up Composer and created it with laravel/laravel from the options menu.
As you can see in the screen shot, the PHP version says 5.6.31.. but if I type php -v in the command line. It gives me php 5.5 (as shown in the bottom left)
If I type php -v in the terminal I also get php 5.6.
which php returns me /usr/local/bin/php
I originally had a problem where PHP would not upgrade to 5.6.. but I managed to solve this with homebrew.
And if I use terminal and cd into the folder to run artisan key:generate and config:clear .. I am able to get the Laravel homepage to load (but typing this from the PhpStorm command line does not work).
My understanding is that the command line is pointing to the directory of PHP that came with my Mac? So how do I point it to the upgraded version? Or is the problem something else?
I think this is a strange problem and already a few people I have asked have not been able to solve it (also setting this up is all very new to me).
what I did is to set an alias on my ~/.bashrc to point php command to point to /Applications/XAMPP/bin/php
e.g. alias php="/Applications/XAMPP/bin/php"
in your case, you can use your XAMPP's full path to your php binary file as you might have different installation paths.
You should be able to add:
export PATH=/Applications/XAMPP/xamppfiles/bin/php5.6.31:$PATH
to your ~/.bash_profile (assuming you're running a bash shell). Then just run source ~/.bash_profile and it should all work.

Composer PHP script running old PHP version causing syntax errors?

I am using composer's post-update-cmd with Laravel. My code is written in PHP 7, I think composer's script call is running an old version because I am getting syntax error on executing php artisan ide-helper:generate. Running the command manually in terminal does not trigger any errors.
How do I specify or configure composer's php to use a specific php path? Using #php, does not seem to work as "artisan" as the path becomes invalid:
You made a reference to a non-existent script #php artisan
ide-helper:generate
Here's my composer.json:
...
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"php artisan optimize"
]
...
I was receiving a similar error (my particular error was with the final script, #php artisan optimize)
Composer was already using PHP 7.1 correctly. Running composer selfupdate fixed this error.
So composer is somehow running the old php even though my ~/.bash_profile is pointing php to a new version.
To prove it, executing php -v was showing PHP 7. Whereas executing composer exec 'php -v' was showing php 5.6.
So after being bothered by this for a few days, I finally tried this. Apparently, the order of ~/.bash_profile matters.
I changed this:
alias composer="php /usr/local/bin/composer.phar"
export PATH=/Applications/MAMP/bin/php/php7.0.8/bin:$PATH
To:
export PATH=/Applications/MAMP/bin/php/php7.0.8/bin:$PATH
alias composer="php /usr/local/bin/composer.phar"
and reload the profile by executing source ~/.bash_profile
Now composer exec 'php -v' shows php 7!
First check the version of your php.
by entering this command to your command prompt(cmd): php -v
If it's showing the wrong version there's a conflict happening.
find the conflicting app by finding the source of your php (cmd): php --ini
the prompt will now tell you where the file is coming from.
You can then uninstall the app that's hosting the old php file. Then your system should automatically use the newer php.

Composer install fails with bus error: 10

I'm trying to install composer with:
curl -sS https://getcomposer.org/installer | php
This fails with the error message:
Bus error: 10
I also tried
php -r "readfile('https://getcomposer.org/installer');" | php
which gives the same error.
I'm on OSX 10.10.3 and PHP 5.6 installed with homebrew.
Any ideas?
That was a nasty one. I actually checked all sorts of things until I discovered that xdebug forces all php scripts to stop in PhpStorm debugger.
Disablling the debugger in PhpStorm obviously solved the problem.
In my case it started to happen after switching back to PHP 5.6 to test a project.
So my php -v in the terminal shows I was using php 5.6, and composer would be also using this version.
I am using valet-plus, and after switching versions everything crashed.
All I had to do was rolling back the php version manually.
$ cd /usr/local/bin
$ rm php (which was a symbolic link to my valet php 5.6)
$ ln -s ../Cellar/valet-php#7.3/7.3.19_1/bin/php php
After that I could update my valet-plus and use php 5.6 in this project with no composer errors (after a valet fix, of course)

Why PHPStorm says "dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib" when I run tests?

Each time I try to run tests with PHPStorm I get this error:
/usr/bin/php /private/var/folders/jl/34t9y2h94jsgchv4wfcxl6g80000gn/T/ide-phpunit.php -c app --configuration /Users/simonegentili/Sviluppo/web/wishventures/SendA/app/phpunit.xml.dist WishVentures\GeeftyApiBundle\Test\Controller\ApiControllerTest /Users/simonegentili/Sviluppo/web/wishventures/SendA/src/WishVentures/GeeftyApiBundle/Tests/Controller/ApiControllerTest.php
Testing started at 18:46 ...
dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/bin/php
Reason: image not found
Process finished with exit code 133
I've found this question but
$ brew update && brew upgrade
$ brew reinstall php55
did not solve my troubles. Well, ... PHPStorm is looking for libpng15.15.dylib, but I've libpng16.16.dylib. I think is a broken link issue. How to solve it?
The reason was that I had two version of php installed on my computer. One reached via /usr/bin/php and another from /usr/local/bin/php. The first one was a link to php version 5.5.8 and the second one was 5.5.14
I sow that dyld (dynamic linker of Operating System) was looking for /usr/local/lib/libpng15.15.dylib (maybe called by php 5.5.8) but inside my /usr/local/lib/ there was not. In that folder, I got libpng16.16.dylib (I think ... because I've installed php55 via brew and this version oh php needs new version of libpng).
I undestood that my /usr/bin/php was a pointer to php 5.5.8. Instead, ... /usr/local/bin/php was 5.5.14. PHPStorm worked with /usr/bin/php that is default configuration. When I run php via console, I run /urs/local/bin/php.

Categories