実現したいこと
Laravelの公式ドキュメント
を見ながらDocker sailを使ったアプリケーションの環境構築を進めています。以下は該当箇所の抜粋です。
Laravel Sailを使用する場合、アプリケーションはDockerコンテナ内で実行され、ローカルコンピューターから分離されます。さらにSailは、任意のPHPコマンド、Artisanコマンド、Composerコマンド、Node / NPMコマンドなど、アプリケーションに対してさまざまなコマンドを実行するための便利な方法も提供します。 **Laravelのドキュメントを読むと、Sailを参照しないComposer、Artisan、Node/NPMコマンドの参照をよく目にするでしょう。**こうした実行例は、これらのツールがローカルコンピューターにインストールされていることを前提としています。ローカルのLaravel開発環境にSailを使用している場合は、Sailを使用してこれらのコマンドを実行する必要があります。 # Artisanコマンドをローカル環境で実行 php artisan queue:work # Laravel Sailの中でArtisanコマンドを実行 sail artisan queue:work
発生している問題・分からないこと
上のコマンドに従って実行したところエラーが出ました。
エラーメッセージ
error
1 2 Illuminate\Database\QueryException 3 4 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: No address associated with hostname (Connection: mysql, SQL: select * from `cache` where `key` = illuminate:queue:restart limit 1) 5 6 at vendor/laravel/framework/src/Illuminate/Database/Connection.php:813 7 809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 8 810▕ ); 9 811▕ } 10 812▕ 11 ➜ 813▕ throw new QueryException( 12 814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 13 815▕ ); 14 816▕ } 15 817▕ } 16 17 i Network address not found: Did you mean to use `sail artisan`? 18 https://laravel.com/docs/sail#executing-artisan-commands 19 20 +40 vendor frames 21 22 41 artisan:13 23 Illuminate\Foundation\Application::handleCommand()
$ php artisan queue:work を実行したとき↑
error
1 UnexpectedValueException 2 3 The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied 4The exception occurred while attempting to log: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.cache' doesn't exist (Connection: mysql, SQL: select * from `cache` where `key` = illuminate:queue:restart limit 1) 5Context: {"exception":{"errorInfo":["42S02",1146,"Table 'laravel.cache' doesn't exist"],"connectionName":"mysql"}} 6 7 at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:137 8 133▕ } 9 134▕ if (!is_resource($stream)) { 10 135▕ $this->stream = null; 11 136▕ 12 ➜ 137▕ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record)); 13 138▕ } 14 139▕ stream_set_chunk_size($stream, $this->streamChunkSize); 15 140▕ $this->stream = $stream; 16 141▕ } 17 18 +12 vendor frames 19 20 13 artisan:13 21 Illuminate\Foundation\Application::handleCommand()
$ sail artisan queue:workを実行したとき↑
### 該当のソースコード
特になし
### 試したこと・調べたこと - [x] teratailやGoogle等で検索した - [ ] ソースコードを自分なりに変更した - [ ] 知人に聞いた - [ ] その他 ##### 上記の詳細・結果 envファイルが間違っているという結果がありましたが、よく分かりませんでした。 ### 補足 WSL2環境を使用しています。phpのバージョンは先ほど8.2にUpdateしました。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2024/05/04 16:10