|
|
(同じ利用者による、間の8版が非表示) |
行1: |
行1: |
− | パッケージ管理ツール
| + | [[php/composer/基本]] |
− | node.jsのnpmみたいなもの。
| + | |
| | | |
− | ==ローカルプロジェクトにcomposerインストール==
| + | [[php/composer/psr-4]] |
− | $ 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)==
| + | [[php/composer/http_request2]] |
− | composer.json | + | |
− | {
| + | |
− | "require": {
| + | |
− | "monolog/monolog": ">=1.0.0"
| + | |
− | }
| + | |
− | }
| + | |
| | | |
− | $ php composer.phar install
| + | [[php/composer/guzzle]] |
| | | |
− | ==autoload==
| + | [[php/composer/Eloquent]] |
− | vender/autoload.phpでパッケージを読み込んでくれる。
| + | |
| | | |
− | ==composer.json編集した後の更新==
| + | [[php/composer/grpc]] |
− | 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をpath登録==
| + | |
− | set_include_path(implode(PATH_SEPARATOR, array(
| + | |
− | realpath(APPLICATION_PATH . '/../vender/pear-pear.php.net/Net_UserAgent_Mobile'),
| + | |
− | get_include_path(),
| + | |
− | )));
| + | |
− | | + | |
− | ==参考==
| + | |
− | http://www.ryuzee.com/contents/blog/5681
| + | |