Laravel deployment build settings

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

  1. Have a local development environment running
  2. Local Laravel installation
  3. Know about deployment features
  4. Install the fortrabbit GitHub app with your GitHub account
  5. Completed Laravel setup steps
  6. Ready for Git deployment.

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
shell

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
shell

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
shell

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.

Written by a human. Review, grammar checks and typo fixes by AI.

AI use & editorial processEdit on GitHub ↗