Deploy a Laravel app and its PostgreSQL database from your AI agent, over MCP
Your AI agent already knows how to write Laravel. Connected to while over MCP, it also deploys your app, in France, with its PostgreSQL database backed up every day and a Laravel Dockerfile ready to go.
By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 2, 2026.
Prerequisites
- A Laravel app, with its composer.json and its artisan file.
- An AI agent that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.
Step 1: Give your agent these instructions
Open your agent in your app’s folder and paste these instructions into it:
Connect to while with my account (while.sh/agents), then deploy my app.
Without an account, your agent deploys your app as a trial, in one request. To keep it, open the link it gives you and create your account.
With your account, your agent adds while’s MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn’t open, type /mcp, choose while, then Authenticate. On that page, choose your app, or “A new app”, then click Authorize.
Step 2: Open your app
Your agent gives you your app’s address, for example https://mon-appli.while.cloud, over HTTPS.
What your agent does
It writes while.yaml at the root of your app:
apiVersion: while/v1
project: mon-appli
services:
- name: web
port: 8080
health:
path: /up
databases:
- name: main
while recognizes Laravel by its composer.json and its artisan file, and your agent gets a Dockerfile ready to build: the Composer dependencies, Apache serving the public folder, and a user without admin rights. Your agent adds it to your app. If your pages load their assets with Vite, the Dockerfile builds them too, and your pages load them over HTTPS.
At startup, the migrations run, then Apache serves your pages. Laravel reads the database address from DB_URL1, which the Dockerfile fills in from DATABASE_URL. The /up route in Laravel 11 and later tells while that your app is ready2. On an older version, your agent adds it. Your agent also generates the APP_KEY key and stores it in while’s secret vault.
Run your queues
You, to your agent: Add a worker for the email queue.
Your agent declares a worker, with the same image and the php artisan queue:work command. Your jobs wait in the PostgreSQL database, which is backed up every day.
Store uploaded files
You, to your agent: Store the files our customers upload.
Your agent adds S3-compatible storage to while.yaml and connects Laravel’s s3 disk to it. Your files survive every deployment.
Run an artisan command every night
You, to your agent: Run the export command every night at 3 am.
Your agent declares a scheduled job that runs your artisan command at the set time, with the same code and the same database. If it fails, your agent is notified.
Restrict your app to your colleagues
You, to your agent: Restrict the app to people in the company.
Your agent adds two lines to the service:
access: internal
email_domains: [acme.com]
Once your Google Workspace or Microsoft 365 is connected to while, on the Pro plan, your colleagues open it with their usual account, and your code receives their name and email address, with no sign-in page to write.
Move to your own domain
You, to your agent: Put the app on app.acme.com.
Your agent declares the domain, you add the DNS records it gives you, and the HTTPS certificate follows.
See a new version before you deploy it
You, to your agent: Show me the new version before you deploy it.
Your agent opens a preview, at its own address, with its own data. You look at it, then your agent puts it into production.
Go back to the previous version
You, to your agent: Go back to the previous version.
In the 30 minutes after a deployment, the previous version comes back in a second. After that, it takes a few seconds. Once the previous version is back, your agent reads what broke in while’s logs, fixes it and deploys again.
In the docs: PostgreSQL databases, Scheduled jobs, Internal access, Custom domain, Previews and Versions and rollback.
Next steps
Sources
- Laravel, database configuration (DB_URL), accessed November 2, 2026
- Laravel, the /up health route, accessed November 2, 2026