【Mac, PHP, Composer】MacにComposerをインストール


## PHPをインストール

Homebrewを使ってcomposerをインストールするにはbrewを使ってインストールしたPHPが必要なため、
Homebrewを使ってPHPをインストールする。
php.iniの場所やPEAR関連の設定についてのコメントなども出ているので、あえてインストールログを全て記載しています。

	$ brew install PHP55	# phpの5.5系のバージョンをインストール

	==> Installing dependencies for php55: libpng, gettext, icu4c, unixodbc
	==> Installing php55 dependency: libpng
	==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.6.13.mavericks.bottle.tar.gz
	######################################################################## 100.0%
	==> Pouring libpng-1.6.13.mavericks.bottle.tar.gz
	?  /usr/local/Cellar/libpng/1.6.13: 17 files, 1.2M
	==> Installing php55 dependency: gettext
	==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gettext-0.19.3.mavericks.bottle.tar.gz
	######################################################################## 100.0%
	==> Pouring gettext-0.19.3.mavericks.bottle.tar.gz
	==> Caveats
	This formula is keg-only, which means it was not symlinked into /usr/local.
	
	Mac OS X provides similar software, and installing this software in
	parallel can cause all kinds of trouble.
	
	OS X provides the BSD gettext library and some software gets confused if both are in the library path.
	
	Generally there are no consequences of this for you. If you build your
	own software and it requires this formula, you'll need to add to your
	build variables:
	
	    LDFLAGS:  -L/usr/local/opt/gettext/lib
	    CPPFLAGS: -I/usr/local/opt/gettext/include
	
	==> Summary
	?  /usr/local/Cellar/gettext/0.19.3: 1920 files, 18M
	==> Installing php55 dependency: icu4c
	==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/icu4c-54.1.mavericks.bottle.tar.gz
	######################################################################## 100.0%
	==> Pouring icu4c-54.1.mavericks.bottle.tar.gz
	==> Caveats
	This formula is keg-only, which means it was not symlinked into /usr/local.
	
	Mac OS X already provides this software and installing another version in
	parallel can cause all kinds of trouble.
	
	OS X provides libicucore.dylib (but nothing else).
	
	Generally there are no consequences of this for you. If you build your
	own software and it requires this formula, you'll need to add to your
	build variables:
	
	    LDFLAGS:  -L/usr/local/opt/icu4c/lib
	    CPPFLAGS: -I/usr/local/opt/icu4c/include
	
	==> Summary
	?  /usr/local/Cellar/icu4c/54.1: 242 files, 65M
	==> Installing php55 dependency: unixodbc
	==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/unixodbc-2.3.2_1.mavericks.bottle.tar.gz
	######################################################################## 100.0%
	==> Pouring unixodbc-2.3.2_1.mavericks.bottle.tar.gz
	?  /usr/local/Cellar/unixodbc/2.3.2_1: 31 files, 1.0M
	==> Installing php55
	==> Downloading http://www.php.net/get/php-5.5.18.tar.bz2/from/this/mirror
	######################################################################## 100.0%
	==> ./configure --prefix=/usr/local/Cellar/php55/5.5.18 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/5.5 --with-config-file-	path=/usr/local/e
	==> make
	==> make install
	==> /usr/local/Cellar/php55/5.5.18/bin/pear config-set php_ini /usr/local/etc/php/5.5/php.ini
	==> Caveats
	To enable PHP in Apache add the following to httpd.conf and restart Apache:
	    LoadModule php5_module    /usr/local/opt/php55/libexec/apache2/libphp5.so
	
	The php.ini file can be found in:
	    /usr/local/etc/php/5.5/php.ini
	
	✩✩✩✩ PEAR ✩✩✩✩
	
	If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
	    chmod -R ug+w /usr/local/Cellar/php55/5.5.18/lib/php
	    pear config-set php_ini /usr/local/etc/php/5.5/php.ini
	
	✩✩✩✩ Extensions ✩✩✩✩
	
	If you are having issues with custom extension compiling, ensure that
	you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
	  1 ### Rubyをrbenvでインストールしたものを利用するように設定
	
	      PATH="/usr/local/bin:$PATH"
	
	PHP55 Extensions will always be compiled against this PHP. Please install them
	using --without-homebrew-php to enable compiling against system PHP.
	
	✩✩✩✩ PHP CLI ✩✩✩✩
	
	If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
	~/.zshrc, ~/.profile or your shell's equivalent configuration file:
	
	      export PATH="$(brew --prefix homebrew/php/php55)/bin:$PATH"
	
	To have launchd start php55 at login:
	    ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents
	Then to load php55 now:
	    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
	==> Summary
	?  /usr/local/Cellar/php55/5.5.18: 493 files, 40M, built in 6.0 minutes

	$ echo 'export PATH=$(brew --prefix)/bin:$PATH' >> ~/.bash_profile	# brewでインストールしたPHPを参照するように設定を変更

	$ echo 'export PATH=$(brew --prefix)/sbin:$PATH' >> ~/.bash_profile	# brewでインストールしたPHPを参照するように設定を変更

	$ source ~/.bash_profile	# 変更した内容を有効化

	$ php -v	# PHPのバージョンを確認し、5.5が使われるようになっていることを確認
	PHP 5.5.18 (cli) (built: Oct 25 2014 17:46:09)
	Copyright (c) 1997-2014 The PHP Group
	Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies


## Composerのインストール

	$ brew search composer	# brewでcomposerが入れられるかどうかを検索
	composer

	$ brew install homebrew/php/composer	# composerをインストール
	==> Downloading http://getcomposer.org/download/1.0.0-alpha8/composer.phar
	######################################################################## 100.0%
	==> Caveats
	Verify your installation by running:
	  "composer --version".
	
	You can read more about composer and packagist by running:
	  "brew home composer".
	==> Summary
	?  /usr/local/Cellar/composer/1.0.0-alpha8: 3 files, 952K, built in 26 seconds