Laravel ✖️ React(inertia.js)環境構築

1.プロジェクトを作成するディレクトリに移動

2.Laravelプロジェクト作成(mac os かつ dockerデスクトップをインストール済前提)

curl -s "https://laravel.build/example-app" | bash

※デフォルトではmysql使用になるので、postgrsqlの場合は↓

curl -s "https://laravel.build/example-app?with=pgsql" | bash

3.Composerを使用してLaravel Breezeをインストール

./vendor/bin/sail composer require laravel/breeze --dev

4.React のインストール

./vendor/bin/sail artisan breeze:install react

5.ビルド

./vendor/bin/sail npm run dev

6.sailを起動

./vendor/bin/sail up -d

7.http://localhost でアクセスできることを確認

 

毎回./vendor/bin/sailを打つのは大変なので、Bashエイリアスの設定がおすすめ。

alias sail='[ -f sail ]bash sail || bash vendor/bin/sail'