Laravel
A Laravel app runs as a PHP site with the framework set to Laravel: nginx serves
public/, the site’s own PHP-FPM pool runs the code, and MZPanel looks after the parts
a Laravel app needs around it: a production .env, the database, migrations, the
scheduler, queue workers and the usual artisan housekeeping. Laravel is one of
the PHP frameworks next to plain PHP and Symfony. It is on every plan, Free
included, like every other site type.
The Laravel jobs below (site.laravel, site.laravel-status, site.artisan and the
laravelScheduler / laravelQueue switches of site.create) need an agent newer than
0.2.174. Older agents answer exit 127: update the agent first.
Create a Laravel site
Section titled “Create a Laravel site”- Open a server’s Sites list and press New site.
- Pick PHP / Laravel, enter the Domain and choose Framework → Laravel. The
document root defaults to
/public. - Optionally set a Git repository (your app instead of a fresh skeleton) and its Branch, the PHP version and a database name. For a private repository, pick it under From a connected account (see Private repositories).
- Keep SSL on auto and create the site.
The agent then:
- creates the app (
composer create-project, or clones your repository); - creates a database: a MariaDB database and user when MariaDB is installed on the
box (
dbName/dbUserpick the names), otherwise a SQLite file; - writes a production
.env:APP_ENV=production,APP_DEBUG=false,APP_URL=https://<domain>, anAPP_KEYand the database settings; - runs the migrations;
- turns on the scheduler and one queue worker (both can be switched off at create time or later).
If any of these steps fails, the job fails with scaffold_failed (it no longer
reports success over a broken app); the message names the step.
Private repositories
Section titled “Private repositories”A PHP site (plain PHP, Laravel or Symfony) can be created from, and atomically deployed from, a private repository through a Git account connected under Git connections (Connect → Git): a GitHub App installation or a personal access token (GitHub, GitLab or Bitbucket). It works the same way as Docker app builds. There are no SSH deploy keys to set up.
- In New site, pick the account and the repository under From a connected
account. The URL and the default branch are filled in. Over the API, send
gitConnectionId(the connection’s id) with anhttps://gitRepo, plusgitBranchif you need a branch other than the default. - For each clone, the control plane gets a fresh token from the connection: a GitHub
App installation token (user
x-access-token) or the stored PAT (user = the connection’s account). The token is never stored in the job, the site registry or.git/config, and is masked in every output line. On the server it reachesgitonly through a short-livedGIT_ASKPASSscript. - The repository must be an
https://URL on the connection’s provider (github.com,gitlab.comorbitbucket.org). Other URLs are refused with400 bad_git_connection. - The site remembers its connection. Later
deploy.runjobs get a fresh token without sendinggitConnectionIdagain.deploy.initto the same repository keeps the connection.deploy.initto a different repository without a connection forgets it. Deleting the site forgets it too. - Members a site is shared with cannot pick a connection (
403 site_permission). Their deploys use the connection the owner set up. - Without
gitConnectionId, nothing changes: public repositories andssh:///git@host:pathURLs clone as before.
The server’s agent must include private-repository support (released after 0.2.180). With an older agent the clone fails with an authentication error; update the agent.
The .env file
Section titled “The .env file”The app’s environment is the .env file in the app folder (or shared/.env once the
site uses atomic deploys, see below). Read and replace it with the same jobs as a
Node.js / Python / Go site’s environment: site.env-get {domain} returns the whole file;
site.env {domain, env} replaces it (env = the full dotenv text, up to 20,000
characters).
site.env is never queued for an offline server (409 server_offline): the queue would
hold the values in clear. After changing .env, run config:cache (or optimize) so a
cached config picks it up.
Scheduler and queue workers
Section titled “Scheduler and queue workers”- The scheduler is a cron entry owned by the site (
/etc/cron.d/mz-site-<user>-scheduler) that runsphp artisan schedule:runevery minute as the site’s user, inside the same sandbox as other site cron jobs. It shows under the site on the Cron page; switch it on or off withsite.laravel, not by editing the entry. - Queue workers are systemd units owned by the site that run
php artisan queue:work(1 to 8 processes). They are restarted after every atomic deploy.
These are part of the site, not Supervisor daemons, so they count against no plan limit and are removed with the site.
Change them with site.laravel:
| Goal | Job body |
|---|---|
| Read the state | {"type": "site.laravel-status", "domain": "app.example.com"} |
| Scheduler off | {"type": "site.laravel", "domain": "app.example.com", "scheduler": false} |
| Queue on, 4 workers | {"type": "site.laravel", "domain": "app.example.com", "queue": true, "queueProcs": 4} |
| Queue off | {"type": "site.laravel", "domain": "app.example.com", "queue": false} |
Leave out a field to keep its current value. Both jobs answer the status object:
{ "ok": true, "domain": "app.example.com", "framework": "laravel", "app_dir": "<the app folder>", "atomic": false, "laravel_version": "12.x", "php_version": "8.4", "env": { "APP_ENV": "production", "APP_DEBUG": "false", "APP_URL": "https://app.example.com", "DB_CONNECTION": "mysql" }, "scheduler": { "enabled": true }, "queue": { "enabled": true, "procs": 1, "active": "active" } }queue.active is the worker unit’s state: active, inactive, failed, or empty when
the queue is off.
Artisan commands
Section titled “Artisan commands”site.artisan runs one artisan command from a fixed list as the site’s user, in the
app folder, and streams its output. There is no free-form command line.
| Command | What it does |
|---|---|
migrate | Run pending migrations (production-safe, no prompt) |
migrate:status | List migrations and whether they ran |
optimize / optimize:clear | Build or clear every cache (config, routes, views, events) |
config:cache / config:clear | Cache or clear the config (run after a .env change) |
route:cache | Cache the routes |
view:cache | Compile the Blade views |
cache:clear | Flush the application cache |
queue:restart | Ask the queue workers to restart after their current job |
storage:link | Create the public/storage symlink |
down | Maintenance mode: the site answers 503 to every visitor until up |
up | Leave maintenance mode |
about | Print the app’s environment overview |
The job ends with {"ok": true, "command": "migrate", "exit_code": 0}. A command that
exits non-zero fails the job and keeps its output in the log.
Atomic deploys
Section titled “Atomic deploys”With a Git repository and the Releases tab (deploy.*, Pro, see
Staging & deploys), each deploy builds a new release folder and
flips the current symlink. For a Laravel site:
.envandstorage/live inshared/and are linked into every release, so they survive deploys and rollbacks;- when you set no build command, the default Laravel build runs:
composer install --no-dev,storage:link,migrate --forceandoptimize; - after the flip, the site’s own PHP-FPM pool is reloaded (OPcache sees the new code) and the queue workers restart.
A rollback switches the code back instantly but does not undo migrations. Keep them backward compatible.
mz site create app.example.com --type php --framework laravel \ --git https://github.com/acme/app.git --db-name app --laravel-queue off --jsonmz site laravel-status app.example.com --jsonmz site laravel app.example.com --queue on --queue-procs 2 --jsonmz site artisan app.example.com migrate --jsonmz site artisan app.example.com down --json # maintenance modeAutomate it (MCP / REST)
Section titled “Automate it (MCP / REST)”Every action is an async job: jobs_create {id: <server UUID>, body: {...}} over MCP,
POST /v1/servers/{id}/jobs over REST. Read the exact fields with
jobs_schema {type} first, then poll jobs_get (or pass wait).
| Goal | Job body | Token level |
|---|---|---|
| Create a Laravel site | {"type": "site.create", "domain": "app.example.com", "siteType": "php", "framework": "laravel", "phpVersion": "8.4", "gitRepo": "https://github.com/acme/app.git", "dbName": "app", "laravelScheduler": true, "laravelQueue": true} | operate |
| Create from a private repo | {"type": "site.create", "domain": "app.example.com", "siteType": "php", "framework": "laravel", "gitRepo": "https://github.com/acme/private-app.git", "gitBranch": "main", "gitConnectionId": "<connection id>"} | operate |
| Read the Laravel state | {"type": "site.laravel-status", "domain": "app.example.com"} | read |
| Scheduler / queue / worker count | {"type": "site.laravel", "domain": "app.example.com", "scheduler": true, "queue": true, "queueProcs": 2} | operate |
| Run migrations | {"type": "site.artisan", "domain": "app.example.com", "command": "migrate"} | operate |
Rebuild caches after an .env change | {"type": "site.artisan", "domain": "app.example.com", "command": "optimize"} | operate |
Read / replace .env | {"type": "site.env-get", "domain": "app.example.com"} · {"type": "site.env", "domain": "app.example.com", "env": "APP_ENV=production\n…"} | operate |
| Enable atomic deploys from a private repo (Pro) | {"type": "deploy.init", "domain": "app.example.com", "repo": "https://github.com/acme/private-app.git", "branch": "main", "gitConnectionId": "<connection id>"} | operate |
| Deploy a release (Pro) | {"type": "deploy.run", "domain": "app.example.com", "ref": "main"} (the remembered connection is used) | operate |
Notes for AI agents:
laravelSchedulerandlaravelQueueare used only withsiteType: "php"andframework: "laravel"; left out, both are on.site.artisanwithcommand: "down"takes the site offline for visitors. Confirm with the user first and runupafterwards.site.envreplaces the whole file: read it withsite.env-get, change the lines, send it back.- None of these kinds is plan-gated except
deploy.*(Pro). - For a private repository, list the org’s Git connections first (
GET /v1/git/connections, statusconnected) and pass theidasgitConnectionId. Never put a token ingitRepo.gitTokenis not an input of these kinds.
Troubleshooting
Section titled “Troubleshooting”A failed create rolls itself back: the Linux user, PHP pool, vhost, database and DB user it made are removed, so you can retry with the same domain.
| Code | Meaning | Fix |
|---|---|---|
scaffold_failed | composer create-project / clone / composer install failed; error.detail holds the output tail | Fix the cause (repository access, composer.json requirements, disk space) and create the site again |
composer_unavailable | Composer could not be installed or verified on the server | Check outbound HTTPS to getcomposer.org, then retry |
ext_missing | A PHP extension Laravel needs could not be installed | Install it with php.ext-install, then retry |
db_failed | The MariaDB database or user could not be created | Check MariaDB is running (db.status); retry or pass another dbName |
bad_db_name / bad_db_user | dbName / dbUser is not a valid MySQL identifier | Use letters, digits and _ |
env_failed / key_generate_failed | The .env could not be written or APP_KEY generated | Check disk space and the site’s file ownership |
migrate_failed / optimize_failed | php artisan migrate --force / optimize failed; error.detail holds the output | Fix the migration or config error in the app, then run site.artisan again |
config_cache_failed | site.env saved the .env but config:cache then failed | Fix the value it complains about and save again |
no_app | site.artisan on a site with no Laravel app deployed yet | Deploy the app first |
bad_git_url / bad_git_branch | gitRepo is not an https://, ssh://, git@host:path or file:// URL, or the branch name is invalid | Fix the URL. For a private repository, use a Git connection (gitConnectionId) |
400 bad_git_connection | The Git connection does not exist in this workspace, or the repository is not an https:// URL on the connection’s provider | Pick a connected account at Connect → Git and use the repository’s https clone URL |
502 git_token_failed | No token could be obtained from the connection (GitHub App uninstalled, PAT missing or unreadable) | Re-verify or reconnect the account at Connect → Git, then retry |
bad_args (job) | The agent got a token with a non-https repository URL | Use the https:// clone URL |
site_user_exists | The site’s Linux user already exists but no site is registered for the domain (not left by an MZPanel create) | Remove that user on the server (userdel -r <user>) or use another domain |
db_exists | The database or DB user named by dbName / dbUser already exists | Pick another dbName / dbUser; MZPanel never takes over an existing database |
not_laravel | site.laravel, site.laravel-status or site.artisan on a site that is not PHP with framework Laravel | Use a Laravel site; for other sites use site.env and the site’s own tools |
bad_command | site.artisan with a command outside the list (the API rejects it as 400 bad_request first) | Pick a command from the table above |
exit 127 | The agent is older than the Laravel support | Update the agent |
- 500 error after deploy? Read
site.logs {domain}andstorage/logs/laravel.login Files. A missingAPP_KEYor a stale config cache are the usual causes: runconfig:clear, thenoptimize. - Jobs pile up in the queue? Check
queue.activeinsite.laravel-status.failedmeans the worker keeps crashing: read the log, fix, thenqueue:restart.
Related
Section titled “Related”- Sites — creating sites of every type.
- Site tools — the Manage drawer.
- Staging & deploys — atomic releases, previews, rollback.
- PHP — PHP versions, extensions and per-site php.ini.