LoginSignup
1
2

Laravelのexample-appをVS CodeのDev Containersで動かす

Last updated at Posted at 2023-05-30

前提

DockerやVisual Studio Codeなどはインストール済みと仮定する。

プロジェクトの作成

適当なディレクトリで以下を実行すると、example-appディレクトリ内にlaravelのアプリが作成される。

curl -s "https://laravel.build/example-app?with=mysql,redis&devcontainer" | bash 

ポイントは、&devcontainerの部分で、これを指定すると、.devcontainer/devcotainer.jsonが自動で作成される。
withクエリでは、mysql,redis,meilisearch,mailpit,seleniumなどが選択可能。

途中でパスワードの入力が求められる。

devcontainerの立ち上げ

example-appディレクトリをVisual Studio Codeで開き、コマンドパレットからDev Containers: Rebuild and Reopen in Containerを選択して、Docker環境が立ち上がる。

サーバーの立ち上げ

コンテナ内で以下を実行することで、サーバーが立ち上がるはずである。

php artisan serve
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2