ksauzz weblog

technical note....

PHP環境メモ

PHPを触ることになったので環境設定をメモ。

とりあえずは phpenv, php-build, composer, phpunit をチョイス。

PHP

install phpenv

1
2
3
4
curl https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh | sh
echo export PATH = ~/.phpenv/bin:$PATH >> ~/.zshrc
echo eval "$(phpenv init - zsh)" ~/.zshrc
source ~/.zshrc

install php-build

1
2
3
4
5
mkdir -p ~/.phpenv/plugins
cd ~/.phpenv/plugins
git clone git://github.com/CHH/php-build.git
curl https://raw.github.com/hnw/php-build/plugin-to-chh-phpenv/bin/rbenv-install > php-build/bin/rbenv-install
chmod 755 php-build/bin/rbenv-install

install php

1
2
brew install libjpeg re2c mcrypt
phpenv install 5.4.8

Composer (Package manager)

install composer

1
curl -s https://getcomposer.org/installer | php && mv -v composer.phar /usr/local/bin/composer

create composer.json

1
2
3
4
5
6
7
8
9
10
11
{
    "config": {
        "bin-dir": "."
    },
    "require": {
        "xxx/xxxx": "2.*"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.*",
    }
}

install dependencies(with require-dev)

1
2
3
composer install --dev
        or
composer update --dev

PHPUnit

configuration file.

create phpunit.xml.dist

1
2
3
4
5
6
7
8
9
10
11
12
<phpunit
    bootstrap="vendor/autoload.php"
    processIsolation="false"
    verbose="true"
    strict="false"
    colors="true">
    <testsuites>
        <testsuite name="PHPUnit">
            <directory>test</directory>
        </testsuite>
    </testsuites>
</phpunit>

run test

1
./phpunit

参考

Comments