Problems with downloading Composer (PHP) on Macbook?

那年仲夏 提交于 2019-12-12 06:26:59

问题


Before I go on, I'm using MAMP(http://www.mamp.info/en/) and I have a Macbook 10.5.8.

I tried typing curl -sS https://getcomposer.org/installer | php in my terminal, but all I get is

Parse error: syntax error, unexpected T_SL in - on line 818 curl: (23) Failed writing body.

If I delete the small "s" in curl -sS, I get:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current Dload  Upload   Total   Spent    Left  Speed
100 32543    0 32543    0     0  25478      0 --:--:--  0:00:01 --:--:-- 82387

Parse error: syntax error, unexpected T_SL in - on line 818

100 48911    0 48911    0     0  32993      0 --:--:--  0:00:01 --:--:-- 81518

but it doesn't do anything.

I even tried to update the path to my PHP thing using this website: "https://gist.github.com/irazasyed/5987693", but my path just stayed the same.

Why is the error happening and how can it be avoided?


回答1:


Sounds like the installed version of PHP is too old. The error is produced by the PHP interpreter (.. | php). Composer requires PHP 5.3+, I believe OS X 10.5.8 did not come with PHP 5.3 out of the box.

You probably want to use the PHP install bundled with MAMP, so substitute the php executable path at the end of the command. I'm not entirely sure what path that is, but something like:

$ curl ... | /Applications/MAMP/bin/.../php

I don't know why this didn't work with your path update.
To see which PHP the php command resolves to:

$ which php

And last but not least, make sure any of your php versions are 5.3+ to begin with:

$ php -v
$ /Applications/MAMP/bin/.../php -v



回答2:


You have to put php client version after | line. I used:

curl -sS https://getcomposer.org/installer | php56-cli

and it works!



来源:https://stackoverflow.com/questions/24137543/problems-with-downloading-composer-php-on-macbook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!