Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.

Create a ZealPHP App

From zero to a running app in under two minutes.

You will learn

  • Install PHP 8.3, OpenSwoole, and ext-zealphp with one command
  • Scaffold a project with composer create-project
  • Start the dev server and verify it works
  • Understand the project folder structure

The problem

Setting up a traditional PHP project means installing PHP, configuring a web server, creating virtual hosts, setting up URL rewriting, and hoping nothing conflicts. With ZealPHP, it's two commands.

Step 1: Install system dependencies

ZealPHP needs PHP 8.3+, the OpenSwoole extension (event loop + HTTP server), and the ext-zealphp extension (for session/header overrides). One script installs everything:

curl -fsSL https://php.zeal.ninja/install.sh | sudo bash

This installs PHP 8.3 (or higher), the openswoole and zealphp extensions, and Composer. It works on Ubuntu, Debian, and macOS.

Step 2: Scaffold a project

composer create-project zealphp/project my-app
cd my-app

This creates a starter project with the right folder structure, a minimal app.php, and all dependencies installed automatically — you can run immediately.

Step 3: Start the server

php app.php

Open http://localhost:8080 in your browser. You should see the starter page.

That’s it. Your app is running. No Apache config, no virtual host, no .htaccess.

The folder structure (in one breath)

The scaffold lays out the directories every ZealPHP app uses: public/ for pages, api/ for REST, route/ for explicit registrations, template/ for layouts, src/ for business logic. We cover each in detail later — the Project Structure lesson has the full layout map and the "where do I put X?" reference table. For now, just know the names exist; you’ll touch public/ first in the next lesson.

CLI commands

The server management works through app.php:

php app.php                # Start (default port 8080)
php app.php start -p 9501  # Start on a specific port
php app.php stop           # Stop the server
php app.php restart        # Restart
php app.php status         # Check if running
php app.php logs           # Tail log files
🔎 What happens when you run php app.php?

OpenSwoole starts an HTTP server inside the PHP process. It forks worker processes (one per CPU core by default), each handling thousands of concurrent connections using coroutines. Your routes, middleware, and templates are loaded once at startup and shared across all requests — unlike traditional PHP where everything is re-loaded per request.

This is why ZealPHP is fast: no bootup cost per request, and the process never dies between requests.

Key Takeaways

  • One install script sets up PHP, OpenSwoole, and ext-zealphp
  • composer create-project scaffolds the app with the right structure
  • php app.php starts the server — no web server config needed
  • Each folder has one job: public/ for pages, api/ for REST, src/ for logic, template/ for layouts