Laravel deployment
Setup automatic git deployment for your Laravel application hosted on fortrabbit.
# 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
# Recommended Laravel build steps
If you import an already existing app from GitHub, we detect what is needed for deployment and you should have sensible defaults already.
But Laravel is versatile. It can act as a backend to exchange with a frontend or it can be used as a monolith. It might be extended with additional software. Therefore deployment build step pipeline options differ.
Laravel Livewire and Laravel Inertia (without Server Side Rendering) should work out of the box.
Because Inertia with SSR (Server Side Rendering) requires a node runtime, this is not currently supported by our platform.
Configure the build steps in the fortrabbit dashboard. These are commonly used:
# Composer build step
In almost all cases you will want to run Composer during deployment for Laravel based applications, see also Composer on fortrabbit.
composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progressshell
# NPM build step
Vite is the default asset bundler for Laravel. For more details on using Vite, see Laravel's docs.
npm install npm run buildshell
This will first install node dependencies. It will then compile the assets and place them in a build folder in the public directory. This folder is by default excluded from the repo in .gitignore.
# Post-deploy commands
Laravel requires a few directories to run correctly.
If you are using a database, you likely will want to run database migrations after you have deployed. We advice to run these post-deploy commands:
mkdir -p storage/framework/{sessions,views,cache} php artisan migrate --forceshell
# Mostly done
Now you should have setup an automatic deployment pipeline that will listen to changes on your GitHub repo branch and deploy these automatically, running the configured build steps.
# Database syncing
Laravel applications with databases may require content syncing from your local development to the environment or the other way around. Please see MySQl import/export guides.
# Additional workflows
The fortrabbit platform is not limited to GitHub deployment. Your application might has runtime data such as uploaded assets that require syncing. Have a look at our deployment features in 'Code VS Content' for options and concepts.
# Laravel installer
Beside the artisan CLI, there is also a laravel installer CLI. It adds a convenience layer installing Laravel and some a lot of commands using the Laravel Cloud solution (bloatware). It can be installed as a global composer dependency.
It's possible, but not recommended, to install and use the laravel installer CLI on the remote environment with fortrabbit. Better use it in your local development environment.