30

I am installing composer with the following cammand

curl -s https://getcomposer.org/installer | php

But I am keep getting below error message

Zafars-MacBook-Pro:etc zafarsaleem$ curl -s 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 detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
detect_unicode = Off

A php.ini file does not exist. You will have to create one.

How can I install composer be removing above error?

EDIT

Zafars-MacBook-Pro:etc zafarsaleem$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Latest Edit

After some research I found that php.ini file which is being used is in /etc/php.ini. However, when I checked this file in /etc folder it wasn't there. /etc folder contained php.ini.default folder which linked to /private/etc/php.ini.default. So I added detect_unicode = Off in /etc/php.ini.default and the renamed this file to php.ini. Now when I execute below command

curl -s https://getcomposer.org/installer | php

OR

sudo curl -s https://getcomposer.org/installer | php

Then I get following errors

Zafars-MacBook-Pro:/ zafarsaleem$ sudo curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
The download failed repeatedly, aborting.

How can I install composer on my computer and remove above problems? Please help

Om3ga
  • 30,465
  • 43
  • 141
  • 221
  • Whats wrong with the message? What concrete problem do you have? – KingCrunch Jan 21 '13 at 11:26
  • It does not install composer. I need to add `detect_unicode = Off` in my `php.ini` file which I did but still I am getting the same error. – Om3ga Jan 21 '13 at 11:27
  • You edited the correct `php.ini`? Every SAPI use their own one. – KingCrunch Jan 21 '13 at 11:27
  • I edited the one in `etc/`. That is the one which is loaded. – Om3ga Jan 21 '13 at 11:30
  • After I run `php -i | grep ini` I get above edited display from where I can get that php.ini is loaded from `etc/` – Om3ga Jan 21 '13 at 11:31
  • Try `php --ini` for a more detailed output – KingCrunch Jan 21 '13 at 12:07
  • @KingCrunch see my second edit above – Om3ga Jan 21 '13 at 12:19
  • have you edited the right php.ini? You probably have a separate one for php-cli – shanethehat Jan 21 '13 at 12:28
  • @KingCrunch Please see my latest updated post. I added some more steps that I did but this time I getting different errors while installing composer. – Om3ga Jan 22 '13 at 06:41
  • @shanethehat Please see my latest updated post. I added some more steps that I did but this time I getting different errors while installing composer. – Om3ga Jan 22 '13 at 06:43
  • @x4ph4r Soooo... What is misleading with "permission denied"? Download the latest phar manually. – KingCrunch Jan 22 '13 at 08:09
  • Composer is satisfied that you have your settings correct. No idea why it would deny permission, but you can download the phar manually from here: https://getcomposer.org/composer.phar (right click, save as...) – shanethehat Jan 22 '13 at 10:00
  • Download failed because your current directory was "/" and you didnt have write permissions there. Please see my instructions below, which i tested on OSX 10.8.2 . – Mike Graf Jan 23 '13 at 16:42
  • 1
    I think the issue was that I was issuing command `curl -s https://getcomposer.org/installer | php` in a folder which did not have write privileges. Below answer helped me to solve this issue. – Om3ga Jan 24 '13 at 05:21
  • I was having this same issue and I fixed my problem by `cd Users` to my Users directory and then into my own user account directory `cd `. I did this on Mac. Everything installed perfectly fine when I got to my `~ $` directory. In case this helps anyone. I ran @Andreyco's command from below. – Graham S. Feb 05 '15 at 18:03

6 Answers6

113

To download / install on MacOSX, you can do the following steps or try the homebrew steps below:

  1. Goto a directory you can write to:

    cd ~

  2. get composer:

    curl -sS https://getcomposer.org/installer | php

  3. move composer into a bin directory in your $PATH var:

    sudo mv composer.phar /usr/local/bin/composer

  4. double check composer works

    composer about

  5. (optional) Update composer:

    sudo composer self-update

Homebrew

brew update
brew tap homebrew/homebrew-php
brew tap homebrew/dupes
brew tap homebrew/versions
brew install php55-intl
brew install homebrew/php/composer
Mike Graf
  • 5,077
  • 4
  • 45
  • 58
  • 1
    I had to run the solution from @Andreyco instead of step 2. – bergie3000 Jul 07 '13 at 06:06
  • 2
    Worked for me as well on Ubuntu 13.10. – jel Oct 23 '13 at 23:24
  • At the risk of sounding stupid...where do you write these commands? Terminal? a PHP page? I'm new to this and have literally no idea where to start – jampez77 Mar 15 '14 at 22:27
  • 1
    @jampez77 , yes in a terminal . – Mike Graf Mar 16 '14 at 03:44
  • note in recent versions of OSX Mavericks(10.9.2), I used `sudo mv composer.phar /bin/composer` to allow it to be ran from "composer" instead of "composer.phar". Hope that helps save you 20 minutes. – cpk Jul 08 '14 at 06:45
  • @cpk is there something superior to moveing to `/bin/composer` vs `/usr/local/bin/composer` ? – Mike Graf Jul 08 '14 at 15:57
  • @MikeGraf No, I just wasn't able to move composer.phar to `/usr/local/bin` as it isn't a directory on my machine, but a file itself. I think there are some new safeguards in place on newer versions of OSX to forbid access `/usr/local/bin/`. – cpk Jul 08 '14 at 16:08
  • I was getting permission denied error when updating the composer. point 5 helped me out. Thanks @MikeGraf – Asbar Mar 12 '15 at 04:59
  • Works in Linux Ubuntu 14.04.2 LTS, too – FredTheWebGuy Apr 22 '15 at 22:20
30

Try this instead and change the setting on the fly, just for this command

curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off
Andreyco
  • 22,476
  • 5
  • 61
  • 65
5

In Ubuntu Vivid 15.04. Try: Steps:

  1. Open terminal and write: sudo su and press Enter.
  2. Paste this: curl -sS https://getcomposer.org/installer | php and press Enter. (This install composer, Wait to finish)
  3. And Finaly Write exit

Note: Sorry, my English is bad :(

nmdaz
  • 99
  • 1
  • 3
4

I had the same error. I ended up adding sudo to the php side and it worked for me.

curl -sS https://getcomposer.org/installer | sudo php
bobbmob
  • 41
  • 2
2

In case if you dont have curl in your system, you can still install composer using the following command

Go to a directory where you can write,

cd yourDirectory

php -r "readfile('https://getcomposer.org/installer');" | php -d detect_unicode=off
0

sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin

Run this command and it will work, so i think :D

Inluxc
  • 2,722
  • 1
  • 12
  • 4