如何在 MAC 上安裝 PHP Composer

下載 Composer v1.6.5

開啟 Mac Terminal 確認你的PHP 是否已經安裝了

# php -v
PHP 7.1.14 (cli) (built: Feb  7 2018 18:33:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

使用 PHP 執行安裝 Composer

# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
# php composer-setup.php (php執行composer-setup)

將composer.phar 移至 /usr/local/bin/composer

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

檢查你的 Composer 版本

# composer -V
Composer version 1.6.5 2018-05-04 11:44:59

在你的資料夾內使用 Composer 安裝 Laravel

# composer create-project --prefer-dist laravel/laravel 你的資料夾名稱 5.6.*
Installing laravel/laravel (v5.6.21)

等下載完後及完成。

PS, 如果你的 Composer 版本過低,可以用下面的令命更新

# composer self-update