Skip to content

Instantly share code, notes, and snippets.

@KEINOS KEINOS/"を追加
Last active Oct 18, 2019

Embed
What would you like to do?
逆引き!Composer コマンド・ライン一覧 ref: https://qiita.com/KEINOS/items/86a16b06af6e936a1841
$ composer config bin-dir bin/
$ COMPOSER=composer-other.json composer install
$ # コマンド・ラインで追記する例
$ composer require [vendor]/[package]
$ # コマンド・ラインで追記する例
$ composer require [vendor]/[package]
$ composer init
$ composer init
$ composer init --require-dev [vendor/package1] [vendor/package2]
composer init --repository '{"type":"vcs","url":"https://github.com/[YOUR]/[REPO]"}' --require [vendor]/[package]:dev-master
$ composer install
$ composer create-project [vendor]/[package]
$ composer install --dry-run
$ composer install
$ composer install --dry-run
$ http_proxy=[URL Proxy] composer install
$ composer update
$ composer install
$ http_proxy=[URL Proxy] composer install
$ composer install
$ http_proxy=[URL Proxy] composer install
$ composer install --dry-run
$ composer update
$ http_proxy=[URL Proxy] composer install
$ composer update --dry-run
$ composer init --require [vendor/package1] [vendor/package2]
$ composer init --require [vendor/package1] [vendor/package2]
$ composer update
$ composer update [vendor]/[package]
$ composer update --dry-run
$ composer update [vendor]/*
$ http_proxy=[URL Proxy] composer install
$ composer outdated
$ http_proxy=[URL Proxy] composer install
$ composer show -lo
$ composer update
$ composer self-update
$ composer update --dry-run
$ composer dump-autoload
$ composer update [vendor]/[package]
$ composer dump-autoload
$ composer update [vendor]/*
$ composer dump-autoload
$ composer outdated
$ composer require [vendor]/[package]
$ composer show -lo
$ composer require
$ ./composer.phar --version
$ php ./composer.phar --version
$ php /path/to/downloaded/composer.phar --version
$ composer init --require vendor/package1:1.0.0
$ composer self-update
$ composer require [vendor]/[package]:dev-master
$ composer dump-autoload
$ composer config repositories.github.com vcs https://github.com/[YOUR]/[REPO]
$ composer dump-autoload
$ composer require [vendor]/[package]:dev-master
$ composer dump-autoload
$ composer config repositories.github.com vcs https://github.com/[YOUR]/[REPO]
$ composer require [vendor]/[package]
$ composer config repositories.github.com '{"type": "vcs", "url": "https://github.com/[YOUR]/[REPO]", "//url": "https://github.com/[YOUR]/[REPO].git"}'
$ composer require
$ composer remove [vendor]/[package]
$ composer config repositories.github.com '{"type": "vcs", "url": "https://github.com/[YOUR]/[REPO]", "//url": "https://github.com/[YOUR]/[REPO].git"}'
"config": {
"bin-dir": "bin/"
}
$ composer require [vendor]/[package]:dev-master
$ composer remove [vendor]/[package]
$ composer require [vendor]/[package]:dev-master
"config": {
"bin-dir": "bin/"
}
$ composer config repositories.github.com vcs https://github.com/[YOUR]/[REPO]
$ composer remove [vendor]/[package1] [vendor]/[package2]
$ # composer.phar があるか確認
$ ls ./
composer.phar
$ # PHP 本体(ランタイム)の保存先ディレクトリを確認
$ dirname $(which php)
$ # PHP と同じディレクトリに拡張子なしで移動し、実行権限を与える
$ mv ./composer.phar $(dirname $(which php))/composer && chmod +x $_
$ # 動作確認
$ composer --version
$ composer init --require-dev [vendor/package1] [vendor/package2]
$ composer config repositories.github.com '{"type": "vcs", "url": "https://github.com/[YOUR]/[REPO]", "//url": "https://github.com/[YOUR]/[REPO].git"}'
$ composer clear-cache
$ composer remove [vendor]/[package1] [vendor]/[package2]
"config": {
"bin-dir": "bin/"
}
$ composer remove [vendor]/[package]
"config": {
"bin-dir": "bin/"
}
$ composer remove [vendor]/[package]
$ composer config repositories.[ID] vcs https://qithub.com/[foo]/[bar]
$ composer remove [vendor]/[package1] [vendor]/[package2]
$ composer config --unset [setting-key]
$ composer remove [vendor]/[package1] [vendor]/[package2]
$ composer help
$ composer clear-cache
$ composer help [command]
$ composer config [options] [setting-key] [setting-value1] ... [setting-valueN]
$ # 検証バージョン
$ composer --version
Composer version 1.9.0 2019-08-02 20:55:32
$ # 作業ディレクトリの作成と移動
$ mkdir hello-world && cd $_
$ # composer の動作確認
$ composer diagnose
...
$ # パッケージの初期化
$ composer init --quiet --name sample/hello-world --require rivsen/hello-world:dev-master
$ # 依存パッケージのインストール
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing rivsen/hello-world (dev-master 82d892b): Cloning 82d892b200 from cache
Writing lock file
Generating autoload files
$ # ディレクトリ構造の確認
$ tree
.
├── composer.json
├── composer.lock
└── vendor
├── autoload.php
├── composer
│   ├── ClassLoader.php
│   ├── LICENSE
│   ├── autoload_classmap.php
│   ├── autoload_namespaces.php
│   ├── autoload_psr4.php
│   ├── autoload_real.php
│   ├── autoload_static.php
│   └── installed.json
└── rivsen
└── hello-world
├── composer.json
├── readme.md
├── src
│   └── Hello.php
└── test.php
5 directories, 15 files
$ # プログラムのファイルを作成
$ touch hello-world.php
$ # プログラムを記載(好きなエディタで。以下は vim )
$ vi hello-world.php
...
$ # プログラムの内容
$ cat hello-world.php
<?php
require_once "vendor/autoload.php";
$hello = new Rivsen\Demo\Hello();
echo $hello->hello(), PHP_EOL;
$ # プログラムの実行
$ php hello-world.php
Hello World!
$ composer config bin-dir phar/
$ composer diagnose
$ composer config repositories.[ID] vcs https://qithub.com/[foo]/[bar]
$ # 検証バージョン
$ composer --version
Composer version 1.9.0 2019-08-02 20:55:32
$ # 作業ディレクトリの作成と移動
$ mkdir hello-world && cd $_
$ # composer の動作確認
$ composer diagnose
...
$ # パッケージの初期化
$ composer init --quiet --name sample/hello-world --require rivsen/hello-world:dev-master
$ # 依存パッケージのインストール
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing rivsen/hello-world (dev-master 82d892b): Cloning 82d892b200 from cache
Writing lock file
Generating autoload files
$ # ディレクトリ構造の確認
$ tree
.
├── composer.json
├── composer.lock
└── vendor
├── autoload.php
├── composer
│   ├── ClassLoader.php
│   ├── LICENSE
│   ├── autoload_classmap.php
│   ├── autoload_namespaces.php
│   ├── autoload_psr4.php
│   ├── autoload_real.php
│   ├── autoload_static.php
│   └── installed.json
└── rivsen
└── hello-world
├── composer.json
├── readme.md
├── src
│   └── Hello.php
└── test.php
5 directories, 15 files
$ # プログラムのファイルを作成
$ touch hello-world.php
$ # プログラムを記載(好きなエディタで。以下は vim )
$ vi hello-world.php
...
$ # プログラムの内容
$ cat hello-world.php
<?php
require_once "vendor/autoload.php";
$hello = new Rivsen\Demo\Hello();
echo $hello->hello(), PHP_EOL;
$ # プログラムの実行
$ php hello-world.php
Hello World!
$ composer init --require vendor/package1:1.0.0
brew install composer
$ composer config --unset [setting-key]
$ composer check-platform-reqs
$ composer show -i
$ composer show --installed
$ composer show
$ composer config --list
$ # 検証バージョン
$ composer --version
Composer version 1.9.0 2019-08-02 20:55:32
$ # 作業ディレクトリの作成と移動
$ mkdir hello-world && cd $_
$ # composer の動作確認
$ composer diagnose
...
$ # パッケージの初期化
$ composer init --quiet --name sample/hello-world --require rivsen/hello-world:dev-master
$ # 依存パッケージのインストール
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing rivsen/hello-world (dev-master 82d892b): Cloning 82d892b200 from cache
Writing lock file
Generating autoload files
$ # ディレクトリ構造の確認
$ tree
.
├── composer.json
├── composer.lock
└── vendor
├── autoload.php
├── composer
│   ├── ClassLoader.php
│   ├── LICENSE
│   ├── autoload_classmap.php
│   ├── autoload_namespaces.php
│   ├── autoload_psr4.php
│   ├── autoload_real.php
│   ├── autoload_static.php
│   └── installed.json
└── rivsen
└── hello-world
├── composer.json
├── readme.md
├── src
│   └── Hello.php
└── test.php
5 directories, 15 files
$ # プログラムのファイルを作成
$ touch hello-world.php
$ # プログラムを記載(好きなエディタで。以下は vim )
$ vi hello-world.php
...
$ # プログラムの内容
$ cat hello-world.php
<?php
require_once "vendor/autoload.php";
$hello = new Rivsen\Demo\Hello();
echo $hello->hello(), PHP_EOL;
$ # プログラムの実行
$ php hello-world.php
Hello World!
$ composer help
$ # 検証バージョン
$ composer --version
Composer version 1.9.0 2019-08-02 20:55:32
$ # 作業ディレクトリの作成と移動
$ mkdir hello-world && cd $_
$ # composer の動作確認
$ composer diagnose
...
$ # パッケージの初期化
$ composer init --quiet --name sample/hello-world --require rivsen/hello-world:dev-master
$ # 依存パッケージのインストール
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing rivsen/hello-world (dev-master 82d892b): Cloning 82d892b200 from cache
Writing lock file
Generating autoload files
$ # ディレクトリ構造の確認
$ tree
.
├── composer.json
├── composer.lock
└── vendor
├── autoload.php
├── composer
│   ├── ClassLoader.php
│   ├── LICENSE
│   ├── autoload_classmap.php
│   ├── autoload_namespaces.php
│   ├── autoload_psr4.php
│   ├── autoload_real.php
│   ├── autoload_static.php
│   └── installed.json
└── rivsen
└── hello-world
├── composer.json
├── readme.md
├── src
│   └── Hello.php
└── test.php
5 directories, 15 files
$ # プログラムのファイルを作成
$ touch hello-world.php
$ # プログラムを記載(好きなエディタで。以下は vim )
$ vi hello-world.php
...
$ # プログラムの内容
$ cat hello-world.php
<?php
require_once "vendor/autoload.php";
$hello = new Rivsen\Demo\Hello();
echo $hello->hello(), PHP_EOL;
$ # プログラムの実行
$ php hello-world.php
Hello World!
$ composer help
$ composer outdated
$ composer show -i
$ composer show --installed
$ composer show -lo
$ composer help [command]
$ composer home
$ composer help [command]
$ composer browse
$ composer config --list
$ composer suggests
$ composer diagnose
$ composer depends [vendor]/[package]
$ composer init
$ composer create-project [vendor]/[package]
$ composer check-platform-reqs
$ composer why [vendor]/[package]
$ composer check-platform-reqs
$ composer depends [vendor]/[package]
$ composer show
$ composer why [vendor]/[package]
$ composer show [vendor]/*
$ composer prohibits [vendor]/[package]
$ composer show [vendor]/[package]
$ composer status
$ composer outdated
$ composer validate
$ composer show -lo
$ composer status
$ composer home
$ composer licenses
$ composer browse
$ composer exec --list
$ composer suggests
$ composer exec
$ composer init
$ composer depends [vendor]/[package]
$ composer exec --list
$ composer why [vendor]/[package]
$ composer exec
$ composer depends [vendor]/[package]
$ composer exec --list
$ composer why [vendor]/[package]
$ composer run-script [script name] [args]
$ composer prohibits [vendor]/[package]
$ composer exec [script name] [args]
$ composer validate
$ composer search [package]
$ composer validate
$ composer status
$ composer licenses
$ composer exec
$ composer init --require [vendor/package1] [vendor/package2]
$ composer exec
$ composer exec --list
$ composer exec
$ composer global config bin-dir --absolute
Changed current directory to /root/.composer
/root/.composer/vendor/bin
$ composer exec --list
$ composer run-script [script name] [args]
$ composer exec [script name] [args]
$ composer global config bin-dir --absolute
Changed current directory to /root/.composer
/root/.composer/vendor/bin
$ composer search [package]
$ composer global config bin-dir --absolute
Changed current directory to /root/.composer
/root/.composer/vendor/bin
$ composer search [package]
$ composer init --require vendor/package1:1.0.0
$ composer install
$ COMPOSER_VENDOR_DIR=hoge composer install
$ composer licenses --format=json
"scripts" :{
"mytest": [
"php --version",
"composer --version",
"php vendor/squizlabs/php_codesniffer/scripts/phpcs",
"php vendor/phpunit/phpunit/phpunit"
]
}
$ composer archive [vendor]/[package] [version] --format=tar
$ composer require [vendor]/[package]:1.*
$ composer self-update 1.0.0-alpha7
$ composer require [vendor]/[package]:2.1
$ composer archive [vendor]/[package] [version] --format=zip
$ composer config bin-dir bin/
$ composer global show -i
$ composer global show --installed
$ # 文法
$ # composer require [vendor]/[package]
$ # 使用例
$ composer require symfony/console
#!/bin/sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT
$ composer search -N [package]
$ COMPOSER_BIN_DIR=fuga composer install
# rivsen/hello-world を依存パッケージとして指定
composer init --quiet --name sample/hello-world --require rivsen/hello-world:dev-master
composer install
$ # composer require [vendor]/[package]
$ composer require keinos/project_x
<?php
require_once "vendor/autoload.php";
$hello = new Rivsen\Demo\Hello();
echo $hello->hello(), PHP_EOL;
$ composer search --only-name [package]
$ # global なし → ./vendor/ 下にインストールされます
$ composer require keinos/project_x
$ # global あり → ~/.composer/vendor/ 下にインストールされます
$ composer global require keinos/project_x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.