Help us understand the problem. What is going on with this article?

Mac SierraにComposerをインストール

More than 3 years have passed since last update.

Mac SierraにComposerをインストール

Wordpressのテスト用にcodeceptionを導入しようとしたが、新しいMacにComposerを入れていなかったのでメモメモ

Composerとは?

Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

ComposerはPHPの依存関係管理ツールである。Composerはプロジェクトが依存するライブラリを明らかにし、インストールやアップデートの管理を可能にする。(意訳)

環境

  • macOS Sierra 10.12.1

Macへのインストール

Homebrewでパッケージインストールです。

$ brew install homebrew/php/composer
Updating Homebrew...
==> Tapping homebrew/php
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-php'...
remote: Counting objects: 660, done.
remote: Compressing objects: 100% (430/430), done.
remote: Total 660 (delta 429), reused 299 (delta 228), pack-reused 0
Receiving objects: 100% (660/660), 278.81 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (429/429), done.
Tapped 636 formulae (676 files, 1.2M)
==> Installing composer from homebrew/php
==> Installing dependencies for homebrew/php/composer: libpng, freetype, icu4c, jpeg, unixodbc, php70
==> Installing homebrew/php/composer dependency: libpng
....
$ composer -V
Composer version 1.2.4 2016-12-06 22:00:51

依存関係にあったphp70もインストールしてくれていますし、パスも通してくれます。

✩✩✩✩ 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/php70)/bin:$PATH"

こんな注意もしてくれるので、どうせなのでPHP-CLIもphp7を使えるようにします。

.bashrcや.zshrcに下記内容を記載します。

# Enable PHP70
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"
$ php -v
PHP 7.0.14 (cli) (built: Dec  9 2016 07:34:25) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

以上で完了です。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away