# Free Laravel hosting

Reverhost runs Laravel, a full-stack PHP framework, in an always-on container built from your Dockerfile, for $0. No credit card is needed, and your agent can deploy it with one instruction.

## What you get

- An always-on container with 256 MB of RAM with no swap, 0.5 CPU and images up to 1 GB
- A URL at `<app-slug>.easyhost.fun`, plus custom domains with HTTPS
- One Postgres 16 database and one S3 bucket per project
- 2 apps per project, with a 128 MB database and 256 MB of storage

## How Laravel builds and runs

| Step | What your Dockerfile runs |
| --- | --- |
| Build | `composer install --no-dev`, then `composer dump-autoload --optimize` |
| Start | `php artisan serve --host=0.0.0.0 --port=$PORT` |
| Runtime env | `PORT=3000` and `HOSTNAME=0.0.0.0` from Reverhost, plus your own variables |

Set `APP_KEY`, `APP_URL` and `LOG_CHANNEL=stderr`, and point `DB_URL` (or `DATABASE_URL` on older versions) at your Reverhost Postgres connection string.

```.env.example
APP_ENV=production
APP_KEY=base64:generate-with-php-artisan-key-generate
LOG_CHANNEL=stderr
DB_CONNECTION=pgsql
DB_URL=postgresql://...
```

## The Dockerfile

```Dockerfile
FROM php:8.3-cli
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends unzip libpq-dev && docker-php-ext-install pdo_pgsql && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist
COPY . .
RUN composer dump-autoload --optimize
ENV APP_ENV=production PORT=3000
EXPOSE 3000
CMD ["sh", "-c", "exec php artisan serve --host=0.0.0.0 --port=$PORT"]
```

Save it as `Dockerfile` in your project folder. It is based on the [PHP template](/languages/php).

## Deploy it

```
npx ezhst projects create my-project --link
npx ezhst apps create my-app
npx ezhst env set APP_KEY=<key> LOG_CHANNEL=stderr DB_CONNECTION=pgsql
npx ezhst build dockerfile set -f Dockerfile
npx ezhst env import .env
npx ezhst deploy
```

## Connect Postgres

```
npx ezhst db create main
npx ezhst db info --json
npx ezhst env set DATABASE_URL="postgresql://..."
npx ezhst redeploy
```

Install `libpq-dev` and run `docker-php-ext-install pdo_pgsql` in the Dockerfile, then connect with PDO using the values from `DATABASE_URL`.

## Limits and caveats

`php artisan serve` suits small apps. Files written to `storage` are lost on the next deploy, so put uploads in the S3 bucket. Run `php artisan migrate --force` from your machine against the connection string.

Apps run in one region, with no edge network, preview deployments or Git integration. See [all frameworks](/frameworks) and [PHP hosting](/languages/php).

## Frequently asked questions

### Is Laravel hosting on Reverhost really free?

Yes. It costs $0 per month with no credit card and no trial period, within the published limits.

### Does my Laravel app sleep when idle?

No. Reverhost apps run in an always-on container and do not sleep when idle.
