Getting Started
This guide walks through setting up a workstation capable of running ZealPHP, verifying prerequisite extensions, creating a new project, and launching the OpenSwoole HTTP server.
1. Prerequisites
- Operating system: Linux distribution with access to
apt, or macOS/Homebrew with equivalent packages. - PHP: >= 8.3 CLI with development headers. Tested on 8.3 and 8.4; PHP 8.5 is supported on OpenSwoole 26.2+ (the CI matrix runs
phpunit (PHP 8.5)). - OpenSwoole: PECL package,
22.1+(current channel:openswoole-22.1.5or later).composer.jsonpinsext-openswoole: ">=22.0"; OpenSwoole 26.2+ (released Feb 2026) adds PHP 8.5 support. Compile with coroutine sockets, OpenSSL, HTTP/2, MySQLnd, CURL, and Postgres support. - uopz: PECL package used to override built-in PHP functions inside the ZealPHP runtime.
- Composer: dependency manager for PHP projects.
Install the core toolchain using apt (recommended):
sudo apt update
sudo apt install gcc php-dev \
openssl libssl-dev curl libcurl4-openssl-dev libpcre3-dev build-essential \
php8.3-mysqlnd postgresql libpq-dev composer
sudo pecl install uopz
sudo pecl install openswoole-22.1.5 # or a newer 22.1.x / 26.2+ release
When prompted during the OpenSwoole build, answer yes to the coroutine and protocol questions so that features such as coroutine sockets and HTTP/2 are enabled.
Automation: the repository ships with
setup.shthat runs the same installation steps. Inspect it before execution if you are operating in a restricted environment.
PHP Extension Configuration
After installing the PECL packages, enable them in the CLI configuration:
sudo tee /etc/php/8.3/cli/conf.d/99-zealphp-openswoole.ini <<'EOF'
extension=openswoole.so
extension=uopz.so
short_open_tag=on
EOF
Verify the modules are loaded:
php -m | grep openswoole
php -m | grep uopz
Both commands should print the module name.
Session unserialize whitelist (v0.2.26). When uopz virtualizes
session_start(), ZealPHP reads$_SESSIONblobs throughunserialize()with['allowed_classes' => ['stdClass']]. Scalars, arrays, andstdClassround-trip normally; any other class read back from session storage becomes__PHP_Incomplete_Class. Adding a class to the whitelist requires reviewing its__wakeup/__unserialize/__destructmagic methods first. Seesrc/Session/utils.phpand thetemplate/pages/sessions.php#objects-in-sessionpage for the canonical reference.
2. Clone and Install Dependencies
Clone the framework and install Composer dependencies:
git clone https://github.com/sibidharan/zealphp.git
cd zealphp
composer install
Composer registers the PSR-4 autoloader for the ZealPHP namespace and pulls in OpenSwoole IDE helpers for better editor integration.
3. Configure Your IDE
- Add
swooleto the Intelephense stubs list. - Include
vendor/openswoole/ide-helperin your editor’s include paths. - Enable short open tags if your editor validates PHP templates (
<?is widely used inside ZealPHP template files).
4. Boot the Development Server
app.php is the binary entrypoint that initializes the ZealPHP runtime, wires middleware, and starts the OpenSwoole HTTP server. Run it directly from the project root:
php app.php
Expected output:
ZealPHP server running at http://0.0.0.0:9501 with N routes
Visit http://localhost:9501 in your browser to exercise the implicit public routes that map to files in public/ — the document root (the Apache DocumentRoot equivalent). It defaults to public/; change it with App::documentRoot('…') before App::init().
5. Verifying Health
- Open a terminal and request a simple page:
You should see a 200 status and the contents ofcurl -i http://localhost:9501/aboutpublic/about.php. - Hit an API endpoint:
Expect a JSON response defined incurl -i http://localhost:9501/api/device/listapi/device/list.php. - Tail application logs (
logs/if configured) or review console output for errors thrown during the request lifecycle.
If the server fails to start with Class "Swoole\HTTP\Server" not found, double-check that extension=openswoole.so is active for the PHP binary you are using.
6. Next Steps
- Review directory-structure.md to understand how ZealPHP arranges routes, APIs, templates, and background tasks.
- Read runtime-architecture.md to learn how ZealPHP virtualizes superglobals, manages sessions, and bridges PSR interfaces with OpenSwoole.