Composer環境を作る
1. phpコンテナに接続
2. Composerインストール
3. 動作確認
docker container exec -it (CONTAINERID) bash
2. Composerインストール
「https://getcomposer.org/」→ [Download] に記載されてある4行をコンテナに張り付けて実行
1.
実行結果:
2.
実行結果:
3.
実行結果:
4.
実行結果:
5. composerを任意のディレクトリから呼び出せるように composer.phar を移動させておく
1.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
実行結果:
root@05fa4e42bbcd:~# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Xdebug: [Log Files] File '/tmp/xdebug.log' could not be opened.
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.25.0.1:9003 (through xdebug.client_host/xdebug.client_port).
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c8b085408188070d5f52bcfe4ecfbee5f727afa458b2573b8eaaf77b3419b0bf2768dc67c86944da1544f06fa544fd47') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
実行結果:
root@05fa4e42bbcd:~# php -r "if (hash_file('sha384', 'composer-setup.php') === 'c8b085408188070d5f52bcfe4ecfbee5f727afa458b2573b8eaaf77b3419b0bf2768dc67c86944da1544f06fa544fd47') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
Xdebug: [Log Files] File '/tmp/xdebug.log' could not be opened.
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.25.0.1:9003 (through xdebug.client_host/xdebug.client_port).
Installer verified
php composer-setup.php
実行結果:
root@05fa4e42bbcd:~# php composer-setup.php
Xdebug: [Log Files] File '/tmp/xdebug.log' could not be opened.
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.25.0.1:9003 (through xdebug.client_host/xdebug.client_port).
All settings correct for using Composer
Downloading...
Composer (version 2.9.7) successfully installed to: /root/composer.phar
Use it: php composer.phar
php -r "unlink('composer-setup.php');"
実行結果:
root@05fa4e42bbcd:~# php -r "unlink('composer-setup.php');"
Xdebug: [Log Files] File '/tmp/xdebug.log' could not be opened.
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.25.0.1:9003 (through xdebug.client_host/xdebug.client_port).
mv composer.phar /usr/local/bin/composer
3. 動作確認
"composer --version" でComposerのバージョンを表示させてみる。
root@8f2ee824c8e9:/var/www/html# composer --version Composer version 2.1.14 2021-11-30 10:51:43
Docker PHP Composer
0 件のコメント:
コメントを投稿