Laravel deployment build settings
Updated
The build commands of a Laravel app on fortrabbit run Composer and, with a package.json, npm to build the Vite assets. Post deploy commands create the storage folders and run the migrations.
Get ready
- Have a local development environment running
- Local Laravel installation
- Know about deployment features
- Install the fortrabbit GitHub app with your GitHub account
- Completed Laravel setup steps
- Ready for Git deployment.
Recommended Laravel build steps
The stack detector and the Laravel template set the build commands for a repository from GitHub. Check them in the dashboard:
- Livewire and Inertia without server-side rendering work as they are. For Filament, see the Filament guide.
- Inertia with server-side rendering needs Node.js at runtime, which fortrabbit does not have: Node.js runs during the build only.
Composer build step
The template runs Composer, see Composer:
composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
NPM build step
Vite bundles the assets of Laravel, see the Laravel docs. With a package.json in the repository, the stack detector adds:
npm install
npm run build
The build writes to public/build, which .gitignore keeps out of the repository.
Post-deploy commands
The template creates the storage folders Laravel needs and runs the migrations after each deployment:
mkdir -p storage/framework/{sessions,views,cache}
php artisan migrate --force
Database and files
Git deploys the code only. Move the database with MySQL export and import, and uploads with rsync, see code moves up, content moves down.