【自分用】4/25 php + dockerの環境構築途中まで


今日のエラー

docker exec -it php php artisan ui vue --authに対して

Command "ui" is not defined. 

composer fundで調べたら下記のエラー

Composer could not find a composer.json file in /Users/user/projects/phpForEveryone
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

再起動してdocker run --rm -v /Users/user/projects/phpForEveryone/src:/app composer require laravel/ui
をもう一度打ったら直った。インターネット接続が不安定のせいでこのコマンドがうまくいっていないのかも...

nmpが入っていないというエラー→nodebrewとnodeをインストールしたら治った。

下記コマンドでpathが合わなくてその下のエラーを出した
→DockerfileのWORKDIR /var/www/html/laravelをコメントアウトしたら治った
docker run --rm -v /Users/user/projects/phpForEveryone/src:/usr/src/app -w /usr/src/app node npm run dev

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/user/projects/phpForEveryone/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/user/projects/phpForEveryone/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2020-04-24T18_09_30_348Z-debug.log

docker-compose exec php php artisan migrateのコマンドで下記のエラー

  Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = laravel_test and table_name = migrations and table_type = 'BASE TABLE')

→.envでDB_HOST=127.0.0.1DB_HOST=mysqlと変更
参考は下記
https://qiita.com/wallkickers/items/47efb41dd200722a98fe