Composer install fails with bus error: 10 - php

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)

Related

zsh: command not found: php. PHP is installed and working with MAMP

I am trying to use composer to install a google client library, but cannot install composer or use php on the command line.
I am using php 8.0.8 with MAMP and it is working fine, so I know it is installed.
If I type php in the terminal, I receive the command not found message. Thinking it could be an environment variable, I have tried navigating to the php folder /Applications/MAMP/bin/php/php8.0.8/lib/php and tried the php command again, but still get the same error
I am using a Mac running Monterey
Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management
Instructions to Change PHP Installation
First, Lets find out what version of PHP we're running (To find out if it's the default version).
To do that, Within the terminal, Fire this command:
which php
This should output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be (Assuming you've not changed it before):
/usr/bin/php
Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/MAMP/bin/php/php5.4.10/bin (MAMP 2.1.3)
To do this, We need to edit the .bash_profile and add the MAMP version of PHP to the PATH variable.
Follow these simple steps:
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Hit ESC, Type :wq, and hit Enter
In Terminal, run source ~/.bash_profile
In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
Install Composer Package Management
Now you can fire the command to install the composer globally (So you can access it from anywhere):
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
You can verify your installation worked by typing the following command within the Terminal:
composer
It'll show you the current version and a list of commands you can use if the installation was successful.
Original source

How to run composer on MAMP 's php version?

I can't run composer install because my php's version on my OS is not enough updated (5.5.36). So i tried to install composer globally with my MAMP's php(5.6.10)
1) I create alias for my MAMP's php
nano ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.6.10/bin/php'
2) Run this line to install composer
curl -sS https://getcomposer.org/installer | phpmamp
3) Run this line to move composer
sudo mv composer.phar /usr/local/bin/composer
Composer is installed (run composer on terminal works)
This is a the tutorial.
But when i want to run composer install, composer uses my OS php.
Any idea ?
Those lines worked for me. I override the OS PHP path to my MAMP PHP path.
PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
$ export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
$ source ~/.bash_profile
You can check the version by running :
$ which php
The complete solution
Thanks to #Andrew Patton
This is an old question, but it came up in web search for a similar issue I was having, and the latest version of MAMP Pro (mine is 6.6.2) has a GUI solution:
In Languages > PHP, under 'Default version', you should see a checkbox for "Also activate shortcut for Composer".
What this did for me is add an alias of composer=/Applications/MAMP/bin/php/composer (in my zshell ~/.profile file on macOS Monterey). Maybe yours works similarly.
Of course, when switching PHP versions, it wouldn't also switch composer versions (which is necessary when switching between PHP 5 and 7.2.5+), so I have to use the OS install for one version and MAMP's for another. A little tricky, but if you don't have this problem, then the alias will be fine.

composer not working in cygwin terminal

when i run the following command in cygwin terminal
$ php -r "readfile('https://getcomposer.org/installer');" | php
!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The json extension is missing.
Install it or recompile php without --disable-json
The phar extension is missing.
Install it or recompile php without --disable-phar
The ctype extension is missing.
Install it or recompile php without --disable-ctype
above error facing , how to solve it, more i have already install xampp, composer_setup.exe , but i want to run composer with cygwin terminal. how to run it ?
A bit too late, but you can try to:
Copy composer.phar to cygwin/usr/bin
Create a new composer.bat file with:
#ECHO OFF
php "%~dp0composer.phar" %*
Then restart cygwin and retry
Additionaly, this can help:
Cygwin/Gitbash + composer = unknown command

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.

composer and php installation conflict for laravel 4 artisan

hi i start working Laravel 4, i have finished the installation process with composer, but when try to use artisan it always give a message
Laravel requires the Mcrypt PHP extension
i have checked with php_info() it shows me Mcrypt PHP extension is enabled, after searching on web i have found some solutions, if i apply those then composer stops working viceversa . i am using XAMPP for development if i use which php command in terminal it show me path /usr/bin/php but my development php is in /Applications/XAMPP/xamppfiles/bin, i have extend the $PATH using .bash_profile
export XAMPP_PHP=/Applications/XAMPP/xamppfiles/bin
export PATH="$XAMPP_PHP:$PATH"
after this artisan start work great but composer stops its working if i type composer command in terminal it show ???? output, now i want composer, php and artisan work perfect just looking for good settings
I solved this problem with a workaround. Instead of changing the $PATH variable, on /usr/bin/ I created a symbolic link to XAMPP's PHP:
cd /usr/bin/
ln -s /Applications/XAMPP/xamppfiles/bin/php phpx
'phpx' is the name I gave to run php on XAMPP (pick the name you prefer - obviously it needs to be different than 'php'). This way I can run artisan using 'phpx' (XAMPP version) which has mcrypt. For example:
phpx artisan key:generate
And if you need to run composer, you run php (mac version):
php composer.phar install
It's a workaround, I'm not proud of it, but it's working.
The best solution would be to install mcrypt on your mac (use this tutorial), mysql and use mac's php. But as a lot of developers (including me) still rely on XAMPP, this workaround may be enough for testing.
If it outputs ???? it most likely means you have detect_unicode = On in your php.ini. This must be off because it breaks phar files.

Categories