facebook twitter hatena line email

「Php/composer」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(composerで入れたpearをpath登録)
 
(同じ利用者による、間の5版が非表示)
行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": "1.0.*",
+
        "pear-pear.php.net/Image_Transform": "0.9.4"
+
    }
+
    "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 . '/../vendor/pear-pear.php.net/PEAR'),
+
    realpath(APPLICATION_PATH . '/../vender/pear-pear.php.net/Net_UserAgent_Mobile'),
+
    get_include_path(),
+
)));
+
 
+
==composer自身のバージョンエラーが出た時==
+
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
+
$ sudo /usr/local/bin/composer self-update
+
 
+
==参考==
+
http://www.ryuzee.com/contents/blog/5681
+

2023年10月20日 (金) 09:22時点における最新版

php/composer/基本

php/composer/psr-4

php/composer/http_request2

php/composer/guzzle

php/composer/Eloquent

php/composer/grpc