Laravel runs happily on a modern app platform, but a few framework habits need adjusting. There is no .env file on the server, the app sits behind a proxy that handles HTTPS, logs must go somewhere you can read them, and migrations need a deliberate place to run.
This tutorial is for developers with a Laravel app in a GitHub repository who want it running in production on Launchpad. You will set the right variables, connect PostgreSQL (MySQL works the same way), decide how migrations run, and see where a Dockerfile gives you more control.
The examples assume Laravel 11 or later and PHP 8.3.
How Launchpad builds a Laravel app
Laravel apps deploy from GitHub only. Zip uploads don't support PHP projects, so push your code to a repository first.
When Launchpad finds composer.json with laravel/framework in its requirements, it:
- Installs dependencies with
composer install --no-dev --optimize-autoloader. - Takes the PHP version from the
phprequirement incomposer.json(for example"php": "^8.3"), and assumes 8.3 if there is none. - Serves the app on port 80.
- Pre-fills the app's variables from your
.env.example.
If the repository also contains a Dockerfile, the Dockerfile wins and Launchpad builds that instead. More on that below.
The variables Laravel needs
Laravel reads its settings from environment variables, so everything that would be in .env goes under the app's Variables tab. Laravel's default .env.example is written for local development (it sets DB_CONNECTION=sqlite, for example), so review the pre-filled values rather than accepting them.
| Variable | Value | Why |
|---|---|---|
APP_KEY | Output of php artisan key:generate --show | Encrypts cookies and sessions; Laravel refuses to run without it |
APP_ENV | production | Turns on production behaviour |
APP_DEBUG | false | Hides error details from visitors |
APP_URL | https:// plus your app's address | Used for generated links and emails |
LOG_CHANNEL | stderr | Sends logs to the platform's log view |
DB_CONNECTION | pgsql or mysql | Picks the database connection |
Generate the key on your own machine and paste it in:
php artisan key:generate --showKeep the same key for the life of the app. Changing it logs everyone out and makes previously encrypted data unreadable.
Connecting the database
Connecting a Launchpad database to the app adds its connection string as DATABASE_URL. Laravel 11 and later read a connection string from DB_URL instead, so map one to the other in config/database.php. In both the pgsql and mysql entries, change the url line:
'url' => env('DB_URL', env('DATABASE_URL')),DB_URL still wins if you set it, and the platform's value is used otherwise. Laravel understands postgres://, postgresql:// and mysql:// schemes, so the string needs no editing. You could paste the connection string into a DB_URL variable instead, but then it won't follow the database if its details change.
Trusting the proxy
HTTPS ends at the platform's proxy, so Laravel sees plain HTTP unless you trust the forwarded headers. Without this, asset URLs and redirects use http:// and browsers block them as mixed content. In bootstrap/app.php:
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: '*');
})Step by step: first deploy
- Make the two code changes above, commit and push.
- In Launchpad, choose Deploy from GitHub, connect the repository and open Step-by-step setup.
- Check that Laravel and your PHP version were detected. Set the Health check path to
/up, the health route Laravel 11 and later include by default. - Fill in the variables from the table. Leave
DATABASE_URLalone; it is added in the next step. - Deploy. Then open the Databases tab, choose New database, pick PostgreSQL and keep Connect it to this app ticked.
- Press Redeploy now and run your migrations as described next.
If your front end uses Vite, public/build must exist in the running app. Add a build command such as npm ci && npm run build under Settings → Build and run and check the build log. If that doesn't suit your project, build the assets in a Dockerfile, as shown below.
Running migrations safely
Be careful here, because the obvious shortcuts cause trouble:
- Not from your laptop. The
DATABASE_URLpoints at the database over your project's private network, which your machine can't reach. - Not in a Composer hook. Hooks such as
post-install-cmdrun during the build, before the app is running and before its database variables are available. - There is no separate release step. Launchpad does not have a field for a one-off command that runs once per deploy.
The dependable approach is a start script that migrates and then starts the server, switched on by a variable. That needs control of the start command, which is what a Dockerfile gives you. Launchpad runs one instance of your app, so two containers won't race to migrate.
If a migration fails, the new version never passes its health check and the previous version keeps running. Because the old version serves traffic while the new one migrates, keep migrations backwards compatible: add columns first, remove them in a later release.
Step by step: a production Dockerfile
- Create
docker/start.sh:
#!/bin/sh
set -e
if [ "$RUN_MIGRATIONS" = "true" ]; then
php artisan migrate --force
fi
php artisan optimize
chown -R www-data:www-data storage bootstrap/cache
exec apache2-foreground- Create
Dockerfileat the top of the repository. Remove theassetsstage and itsCOPYline if you don't use Vite:
FROM node:22-slim AS assets
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM php:8.3-apache
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl git unzip libpq-dev libzip-dev \
&& docker-php-ext-install pdo_pgsql pdo_mysql zip opcache \
&& rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
&& a2enmod rewrite
WORKDIR /var/www/html
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-interaction
COPY . .
COPY --from=assets /app/public/build ./public/build
RUN composer dump-autoload --optimize --no-dev \
&& chown -R www-data:www-data storage bootstrap/cache \
&& chmod +x docker/start.sh
EXPOSE 80
CMD ["/var/www/html/docker/start.sh"]- Add a
.dockerignoreso local files stay out of the image:
.env
.git
node_modules
vendor
storage/logs/*- Add
RUN_MIGRATIONSwith the valuetrueunder Variables, commit and push.
EXPOSE 80 tells Launchpad the port. curl is installed because Launchpad checks health from inside the container. php artisan optimize caches config, routes and views at start-up, when the variables are available. After caching, env() only works inside config files, which is Laravel's normal production rule.
Queues and the scheduler
Launchpad has no cron scheduler, and each app runs a single start command, so plan for this:
- Small apps: set
QUEUE_CONNECTION=syncso jobs run during the request. Simple, but slow jobs slow the response. - With the Dockerfile: start a worker and the scheduler in the background in
start.sh, before theexecline:php artisan queue:work --tries=3 &andphp artisan schedule:work &. Nothing restarts them if they crash until the next deploy, so keep jobs short and watch the logs. - Heavier workloads: run workers on a separate server, or move timed tasks to an external scheduler that calls a protected endpoint.
Common mistakes
APP_DEBUG=truein production. Error pages expose configuration. Fix: set it tofalse.- Missing
APP_KEY. Every page fails. Fix: generate one and add it under Variables. DB_CONNECTION=sqliteleft from.env.example. Data goes to a file that disappears on redeploy. Fix: setpgsqlormysql.- Logs written to
storage/logs. You never see them. Fix:LOG_CHANNEL=stderr. - User uploads in
storage/app. They are lost on redeploy. Fix: use S3-compatible storage, or a disk rooted in the app's/datafolder, which is kept across deploys and backed up daily.
Security notes
- Never commit
.env. Variables on Launchpad are stored encrypted and never written to logs. - Treat
APP_KEYlike a password. Anyone with it can forge encrypted cookies. - Run
composer auditregularly and keep Laravel on a supported release. - Only trust all proxies (
at: '*') when the app is reachable solely through the platform's proxy, as it is on Launchpad.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| "No application encryption key has been specified" | APP_KEY missing | Generate it and Redeploy now |
| Deploy fails the health check | Path redirects or returns an error | Use /up; check the app logs |
| Styles missing, mixed-content warnings | Proxy not trusted, or APP_URL uses http | Add trustProxies; use an https APP_URL |
could not find driver | PHP extension for your database missing | Use the Dockerfile above, or require ext-pdo_pgsql in composer.json |
relation "sessions" does not exist | Migrations not run | Set RUN_MIGRATIONS=true and redeploy |
Frequently asked questions
Can I upload a zip of my Laravel app instead?
No. Zip uploads support static sites, Node apps and Python apps. Laravel and other PHP apps deploy from GitHub.
Do I need the Dockerfile?
Not to get started. The automatic build serves a Laravel app without one. Add it when you want migrations on deploy, background workers or specific PHP extensions.
Does this work with MySQL?
Yes. Create a MySQL database instead, set DB_CONNECTION=mysql, and make sure the mysql entry in config/database.php has the same url line.
Which PHP version runs my app?
With the automatic build, the version in your composer.json php requirement. With the Dockerfile, the base image you choose (php:8.3-apache above).
Next steps
Your Laravel app now has production settings, a database connection that follows the platform, and a deliberate way to migrate. The next job is usually a custom domain and an automated test run before each push.




