「Php/composer」の版間の差分
提供: 初心者エンジニアの簡易メモ
行62: | 行62: | ||
} | } | ||
$ vendor/bin/phpunit --bootstrap vendor/autoload.php tests/hoge.php | $ vendor/bin/phpunit --bootstrap vendor/autoload.php tests/hoge.php | ||
+ | |||
+ | ==composerで入れたpearをライブラリ登録== | ||
+ | set_include_path(implode(PATH_SEPARATOR, array( | ||
+ | realpath(APPLICATION_PATH . '/../vender/pear-pear.php.net'), | ||
+ | get_include_path(), | ||
+ | ))); | ||
==参考== | ==参考== | ||
http://www.ryuzee.com/contents/blog/5681 | http://www.ryuzee.com/contents/blog/5681 |
2016年2月5日 (金) 05:44時点における版
パッケージ管理ツール node.jsのnpmみたいなもの。
目次
ローカルプロジェクトにcomposerインストール
$ curl -s http://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer.phar $ composer -V Composer version e77435cd0c984e2031d915a6b42648e7b284dd5c 2014-07-02 15:44:54
使い方(例:monolog/monolog)
composer.json
{ "require": { "monolog/monolog": ">=1.0.0" } }
$ php composer.phar install
autoload
vender/autoload.phpでパッケージを読み込んでくれる。
composer.json編集した後の更新
composer update
vendorのdirの名前を変更
composer.json
{ "require": { "monolog/monolog": ">=1.0.0" }, "config": { "vendor-dir": "lib/" } }
composer.json記述例
{ "repositories": [ { "type": "pear", "url": "http://pear.php.net/" } ], "require": { "pear-pear.php.net/PEAR": "1.9.*", "pear-pear.php.net/Mail": "1.2.*", "pear-pear.php.net/Mail_Mime": "1.8.*", "pear-pear.php.net/Net_SMTP": "1.6.*", "pear-pear.php.net/Net_UserAgent_Mobile": "*" } "require-dev": { "phpunit/PHPUnit": "5.1.*" }, }
phpunitのinstall&実行例
{ "require-dev": { "phpunit/phpunit": "5.1.*" } } $ vendor/bin/phpunit --bootstrap vendor/autoload.php tests/hoge.php
composerで入れたpearをライブラリ登録
set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../vender/pear-pear.php.net'), get_include_path(), )));