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 uopz 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 uopz 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 uopz PECL extensions, and Composer. It works on Ubuntu, Debian, and macOS.

Step 2: Scaffold a project

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

This creates a starter project with the right folder structure, a minimal app.php, and all dependencies pre-installed (the scaffold ships vendor/ so 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

Here's what the scaffold created:

my-app/
├── app.php              # Entry point — middleware, routes, $app->run()
├── public/              # Pages — each .php file becomes a URL
│   └── index.php        # → GET /
├── api/                 # REST endpoints — file-based routing (ZealAPI)
├── route/               # Advanced routes — WebSocket, Store tables, path params
├── template/            # Layouts and reusable components
│   ├── _master.php      # Page layout shell (nav + content + footer)
│   └── pages/           # Page-specific content
├── src/                 # Business logic — PSR-4 autoloaded classes
├── storage/             # SQLite databases, uploaded files
└── vendor/              # Composer dependencies

The key rule: each folder has one job.

  • public/ — Pages the user visits. Files map directly to URLs.
  • api/ — REST endpoints. Each file defines one closure.
  • src/ — Business logic. Classes, services, helpers — autoloaded.
  • template/ — HTML layouts and reusable components.

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 uopz
  • 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