- 1. 概要
- 2. 準備
- 3. 追加
- 4. 後始末
1. 概要
稼働中の「Laravel」のプロジェクトに、後付けで、パッケージを追加する方法について、記述します。
よくやっている、「phpmailer」を例示します。
ここでは、プロジェクト名を「examine」としておき。
/usr/local/www/examine
に存在するものとします。
所有するログインユーザを「hogehoge」としておきます。
2. 準備
稼働中であれば、「apache」の停止か、「Laravel」のサイトをアクセスできないようにしておきます。
わたしの場合、プロジェクトの所有権をログインユーザにして、キャッシュ等の所有権を「www」としているので、パッケージインストール用に、所有権をいったん、変更します。
「root」ユーザ権限で。
chown -R hogehoge:hogehoge /usr/local/www/examine/bootstrap/cache
chown -R hogehoge:hogehoge /usr/local/www/examine/storage/framework
chown -R hogehoge:hogehoge /usr/local/www/examine/storage/logs
chown -R hogehoge:hogehoge /usr/local/www/examine/database/database.sqlite
3. 追加
ログインユーザで。
composer require phpmailer/phpmailer
下記のようなメッセージが出力されます。
./composer.json has been updated
Running composer update phpmailer/phpmailer
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking phpmailer/phpmailer (v6.9.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading phpmailer/phpmailer (v6.9.3)
- Installing phpmailer/phpmailer (v6.9.3): Extracting archive
5 package suggestions were added by new dependencies, use 'composer suggest' to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
INFO Discovering packages.
laravel/pail ............................................................................................. DONE
laravel/sail ............................................................................................. DONE
laravel/tinker ........................................................................................... DONE
nesbot/carbon ............................................................................................ DONE
nunomaduro/collision ..................................................................................... DONE
nunomaduro/termwind ...................................................................................... DONE
81 packages you are using are looking for funding.
Use the 'composer fund' command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
INFO No publishable resources for tag [laravel-assets].
No security vulnerability advisories found.
Using version ^6.9 for phpmailer/phpmailer
4. 後始末
変えた所有権をもとに戻します。
「root」ユーザ権限で。
chown -R www:www /usr/local/www/examine/bootstrap/cache
chown -R www:www /usr/local/www/examine/storage/framework
chown -R www:www /usr/local/www/examine/storage/logs
chown -R www:www /usr/local/www/examine/database/database.sqlite
|