Laravel (PHP)
Laravel is a popular PHP framework for building robust web applications with expressive, elegant syntax. It provides a powerful routing system, ORM (Eloquent), queueing, caching, background jobs and more.
Check out the official documentation here.
Deploy a Laravel App
Deployment Instructions
We recommend using a Dockerfile as the build system for production deployments on Hostless. This ensures consistent, reproducible builds.
-
Create or use an existing Laravel repository
-
Click on 'Create New App' on Hostless
-
Choose a suitable app name
-
Choose your Git provider account
-
Select your Laravel repository
-
Choose a build system
- 'Docker' — Hostless looks for a
Dockerfilein the repository root and builds the image according to your instructions
- 'Docker' — Hostless looks for a
-
(Optional) Input a start command if you want to override the image CMD
-
Hostless automatically sets the
PORTenvironment variable your app should listen on -
Ensure your Laravel app reads the port from
$_ENV['PORT'](or default to 8080) when configuring your web server (e.g., PHP-FPM + Nginx or Caddy) -
Set production environment variables:
APP_ENV=productionAPP_DEBUG=falseAPP_KEY(required; generate viaphp artisan key:generate --showand copy the value)- Database credentials (e.g.,
DB_CONNECTION,DB_HOST,DB_PORT,DB_DATABASE,DB_USERNAME,DB_PASSWORD) - Any other necessary secrets (e.g., cache/session drivers, queues, mailer)
Example Dockerfile (Multi-stage)
# Build stage
FROM composer:2 AS vendor
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
# App stage
FROM php:8.2-fpm-alpine AS app
WORKDIR /var/www/html
# Install system deps as needed (pdo, gd, etc.)
RUN docker-php-ext-install pdo pdo_mysql
COPY . .
COPY --from=vendor /app/vendor ./vendor
# Cache/config optimize for production
RUN php artisan config:cache && \
php artisan route:cache && \
php artisan view:cache || true
# Web server stage (Caddy example)
FROM caddy:2-alpine AS web
WORKDIR /srv
# Copy app code
COPY --from=app /var/www/html /srv
# Caddyfile expects PORT from env
# Example Caddyfile
# :{$PORT}
# php_fastcgi 127.0.0.1:9000
# file_server
# Run PHP-FPM alongside Caddy (in production you might prefer separate processes or s6/supervisord)
# For simplicity, consider a single-process server like RoadRunner or FrankenPHP if suitable
Note: You can use Nginx instead of Caddy. The key point is to forward requests to PHP-FPM and listen on the
$PORTvalue provided by Hostless.
Environment Variables
PORT— set by Hostless at runtime. Ensure your web server listens on this port.APP_ENV—productionAPP_DEBUG—falsein productionAPP_KEY— required; keep secretDB_*— database connection details
Health Checks
Configure a lightweight route like /health that returns 200 OK to use as an HTTP health check path in the app configuration.
Logs & Metrics
- Application logs are collected from STDOUT/STDERR and visible in the Hostless dashboard
- Use Laravel Telescope or external APM if you need deeper insights