PHPackages                             sibidharan/zealphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sibidharan/zealphp

ActiveLibrary[Framework](/categories/framework)

sibidharan/zealphp
==================

A dynamic PHP web development framework built with OpenSwoole.

v0.1.0(7mo ago)24759[1 PRs](https://github.com/sibidharan/zealphp/pulls)1MITPHPPHP &gt;=8.3

Since Dec 19Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/sibidharan/zealphp)[ Packagist](https://packagist.org/packages/sibidharan/zealphp)[ Docs](https://php.zeal.lol)[ RSS](/packages/sibidharan-zealphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (1)

ZealPHP - an opensource PHP framework that runs on OpenSwoole
=============================================================

[](#zealphp---an-opensource-php-framework-that-runs-on-openswoole)

A powerful light weight opensource alternative to NextJS - that uses OpenSwoole's Async IO to do everything NextJS can and do much more.

[![Latest Stable Version](https://camo.githubusercontent.com/9188df61e6675f669a76bc7d41a62c8a99bd7e72765a2aa539211e429337b136/68747470733a2f2f706f7365722e707567782e6f72672f7369626964686172616e2f7a65616c7068702f76)](https://packagist.org/packages/sibidharan/zealphp) [![Total Downloads](https://camo.githubusercontent.com/a3b6d4566f6d6c53945e6265d4fde4161cdf6e1a3418b90a86bcfccae33fda0c/68747470733a2f2f706f7365722e707567782e6f72672f7369626964686172616e2f7a65616c7068702f646f776e6c6f616473)](https://packagist.org/packages/sibidharan/zealphp) [![Latest Unstable Version](https://camo.githubusercontent.com/c803f6f419e6b2d7612787dbd684afe9ffa81c0ef0aa0358c935992970f63904/68747470733a2f2f706f7365722e707567782e6f72672f7369626964686172616e2f7a65616c7068702f762f756e737461626c65)](https://packagist.org/packages/sibidharan/zealphp) [![License](https://camo.githubusercontent.com/93c4080b489af229e7e9c1092019bfbb8bca946460af1ba20cbeefbc4a4cafb0/68747470733a2f2f706f7365722e707567782e6f72672f7369626964686172616e2f7a65616c7068702f6c6963656e7365)](https://packagist.org/packages/sibidharan/zealphp)

Homepage: Changelog: [CHANGELOG.md](CHANGELOG.md)

Features:

1. Dynamic HTML Streaming with APIs and Sockets
2. Parallel Data Fetching and Processing (Use go() to run async coroutine)
3. Dynamic Routing Tree with Implicit Routes for Public and API
4. Programmable and Injectable Routes for Authentication
5. Dynamic and Nested Templating and HTML Rendering
6. Workers, Tasks and Processes
7. All PHP Superglobals are constructed per request

Get Started
===========

[](#get-started)

1. Install OpenSwoole - PHP Server with Asynchronous IO
-------------------------------------------------------

[](#1-install-openswoole---php-server-with-asynchronous-io)

Before configuring OpenSwoole, we need to install its dependencies.

**It is highly recommended to run `apt update` to refresh the system’s package index.** This ensures all package versions are up-to-date and avoids installation errors.

Install the GCC Compiler

```
$ sudo apt install gcc

```

Required for PECL installation and manual OpenSwoole compilation

```
$ sudo apt install php-dev

```

Main requirements for OpenSwoole and useful packages

```
$ sudo apt install openssl libssl-dev curl libcurl4-openssl-dev libpcre3-dev build-essential php8.3-mysqlnd postgresql libpq-dev

```

Now lets install OpenSwoole. Compared with other async programming frameworks or software such as Nginx, Tornado, Node.js, Open Swoole is a complete async solution that has built-in support for async programming via fibers/coroutines, a range of multi-threaded I/O modules (HTTP Server, WebSockets, GRPC, TaskWorkers, Process Pools) and support for popular PHP clients like PDO for MySQL, Redis and CURL.

ZealPHP uses OpenSwoole and offers a Web Development Framework that offers APIs, Routes, Sessions, Superglobals, Impicit Routing, Templating, Dynamic Injection, Dynamic HTML Streaming and much more that brings modern web development paradigms for your favorite language. ZealPHP also overrides some of PHP's inbuilt functions, for this to work, we use `uopz` extension and it is needed for ZealPHP to work. This wont take much longer to install, so before installing openswoole, lets install this.

### Install uopz

[](#install-uopz)

`uopz` is a PECL extension that allows for the manipulation of user-defined functions and classes. It is useful for testing and debugging by allowing you to mock functions and classes. In ZealPHP, we use the `uopz` library to override built-in PHP functions such as `header` and `setcookie` within the ZealPHP context.

```
$ sudo pecl install uopz

```

### Install OpenSwoole

[](#install-openswoole)

Installation of OpenSwoole will take a while, grab a cup of coffee ☕

```
$ sudo pecl install openswoole-22.1.2

```

Now the building process will start, and within seconds you need to answer a few questions as follows for the compiling to begin. Compilation will take sometime depending on your CPU.

```
enable coroutine sockets? [no] : yes
enable openssl support? [no] : yes
enable http2 protocol? [no] : yes
enable coroutine mysqlnd? [no] : yes
enable coroutine curl? [no] : yes
enable coroutine postgres? [no] : yes

```

After a lot of console messages, the build process should end with these messages

```
Build process completed successfully
Installing '/usr/lib/php/20230831/openswoole.so'
Installing '/usr/include/php/20230831/ext/openswoole/config.h'
Installing '/usr/include/php/20230831/ext/openswoole/php_openswoole.h'
install ok: channel://pecl.php.net/openswoole-22.1.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=openswoole.so" to php.ini

```

According to your PHP version, you simply need to add `extension=openswoole.so` and `extension=uopz.so` in your php.ini file. I am using PHP 8.3 in this case.

```
$ cd /etc/php/8.3/cli/conf.d

$ sudo touch 99-zealphp-openswoole.ini
$ echo "extension=openswoole.so" | sudo tee -a /etc/php/8.3/cli/conf.d/99-zealphp-openswoole.ini
$ echo "extension=uopz.so" | sudo tee -a /etc/php/8.3/cli/conf.d/99-zealphp-openswoole.ini

# Enable Short Open Tags for Flexibility
$ echo "short_open_tag=on" | sudo tee -a /etc/php/8.3/cli/conf.d/99-zealphp-openswoole.ini

```

We are good to go. Let's check if the setup is working.

```
$ php -m | grep openswoole
openswoole
$ php -m | grep uopz
uopz

```

If it prints `openswoole` and `uopz` then the modules are loaded and are ready to go.

2. Installing Composer (skip if already done)
---------------------------------------------

[](#2-installing-composer-skip-if-already-done)

We are going to rely on `composer`. So install it if not already done.

```
$ sudo apt install composer

```

Now lets get started.

3. Getting started with ZealPHP Framework
-----------------------------------------

[](#3-getting-started-with-zealphp-framework)

ZealPHP `v0.1.0` is available on Packagist for both the framework and the project template. Use the stable tag when scaffolding a new application as shown below.

**Note: Ensure you are in the correct directory**

Before running the command, make sure you navigate to the directory where you want to save your project.

```
$ composer create-project sibidharan/zealphp-project:^0.1 my-project

```

Already have an application and just want the framework runtime?

```
$ composer require sibidharan/zealphp:^0.1

```

With composer installed, lets run our ZealPHP Project

```
$ cd my-project
$ composer update
$ php app.php

ZealPHP server running at http://0.0.0.0:8080 with 8 routes

```

4. Understanding what is happening
----------------------------------

[](#4-understanding-what-is-happening)

When you run `app.php` the openswoole server is being run and managed by ZealPHP. It will stay attached to your terminal unless you deamonize, which we wont be doing while development. When moving to production, you can do `$app->run(['daemonize'=>true])` to the run function, which detaches the running script in background. This can be configured to systemctl to run on boot, or to run behind Apache or Nginx. The `run` function can take all OpenSwoole Configuration as mentioned in . Unlike Apache+PHP setup, the functions of Apache like URL Rewriting, Superglobals is replaced by ZealPHP, while OpenSwoole is offering the server. ZealPHP is offering the routing with a very efficient route tree model, which is O(1) in code injection and lookup. On top of that, ZealPHP offers implicit routes that serves the files located under `public` and `api` directories. These routes can be overridden by you.

You can start by defining your routes in `app.php` or under `route` directory which gets imported automatically when you run `app.php`. See the code examples in this project to understand dynamic route injection using `route` folder. This comes handy to maintain large projects, and also maintain a healthy project structure.

You can start writing APIs out of the box without any additional configuration. Look inside `api `folder for more examples. To understand more on how to handle the response, please wait for the documentation or you can checkout  for more development examples.

Any and all contributions are welcome ❤️

Publishing releases
-------------------

[](#publishing-releases)

1. Ensure the documentation and metadata (including `CHANGELOG.md`) capture the upcoming version number and notable changes.
2. Run `composer validate` and project checks to confirm the package installs cleanly.
3. Tag both repositories in lockstep (`zealphp` and `zealphp-project`) with the same version, for example `git tag -a v0.1.0 -m "Release v0.1.0"`.
4. Push the main branch and the tag to every remote for each repository (`git push origin master && git push origin v0.1.0`, etc.).
5. Visit Packagist (or call the webhook) for both packages so the new tags are indexed and the `v0.1.0` constraint becomes available.

ZealPHP Design Principles
=========================

[](#zealphp-design-principles)

- Integrating OpenSwoole is a very good move but reaping the full performance of the coroutines and still being able to run an Apache/FPM styled web server with powerful in-memory dynamic nested ZealPHP template render functions while reconstructing superglobals on top of all these comes with a cost. The ZealPHP Server won't enable coroutines for the HTTP server by default, so the main response thread can't run `go()` calls. Instead of the server processes sharing the superglobal memory while running coroutines, we disable coroutines for the server process. To understand what is happening, let's say if a main thread is waiting for an IO or sleeping, the same server worker process will be used to serve another request. This new request will cause the superglobals to overwrite the ones waiting for IO and cause data leak/corruption. We decide to disable coroutines in the main thread, which enables us to support PHP superglobals in an Apache styled way.
- To support incremental adoption of async capabilities and still be able to reap the benefits of coroutines alongside backward compatibility for traditional PHP applications, ZealPHP introduces a function called `coprocess` alias `coproc` that enables you to create a process that has coroutine context, and you can run as many fibers/coroutines inside that process. This function keeps the design pattern clean, and each server worker deals with one request at a time, thus we can use the superglobals while reaping maximum performance on demand.
- `coproc` creates a process which has its own memory space, it is like a fork, so communicating with that process cannot be over superglobals, and the data passing needs to be done delicately. The StdOut is returned. `coproc` is a wrapper to `OpenSwoole\Process` with coroutines enabled and StdIO forwarded. It also makes sharing variables as easy as copying them into the memory before the process forks, then the data is available to the new process. But the limitation here is we cannot pass anything that is not serializable. For example, Database Connection, Sockets, FD, etc. Those unserializable objects have to be reconstructed inside the `coproc`. This design decision may change in the future with us removing support for superglobals with our own implementation. More research and development is needed in this area. (Still in development, documentation will be available later)
- The tradeoff between having superglobals and not using coroutines in the main server process and the implications of security here are still to be researched, and a more stable and sustainable design pattern has to be arrived at. ZealPHP decides to sanitize every request with a default middleware which can be overridden if needed.
- But this is optional. If you want coroutines in the ZealPHP main HTTP server, you just have to turn off superglobals using `App::superglobals(false);` and `Coroutines` will be enabled automatically. To have backward compatibility and to educate users about the design of ZealPHP and OpenSwoole, the default option comes with superglobals enabled. Deliberately requiring users to disable it for using coroutines helps user awareness about what's going on.

Common Errors
=============

[](#common-errors)

### 1. When openswoole is not installed and configured

[](#1-when-openswoole-is-not-installed-and-configured)

```
└❯ php app.php
PHP Fatal error:  Uncaught Error: Class "Swoole\HTTP\Server" not found in /var/labsstorage/home/sibidharan/zealphp/src/App.php:322
Stack trace:
#0 /var/labsstorage/home/sibidharan/zealphp/app.php(100): ZealPHP\App->run()
#1 {main}
  thrown in /var/labsstorage/home/sibidharan/zealphp/src/App.php on line 322

```

### Summary steps needed to configure ZealPHP Project

[](#summary-steps-needed-to-configure-zealphp-project)

1. Install OpenSwoole using pecl `sudo pecl install openswoole-22.1.2`

    - Enable curl coroutines and coroutine sockets, if curl.h error throws, `sudo apt install libcurl4-openssl-dev`
2. Add the extension to php.ini (cli prefered)
3. Check if openswoole is configured properly `php -m | grep swoole`

Until this point, the `setup.sh` can do it for you.

4. Run `php app.php`> > > ZealPHP server running at

Configure IDE for Smooth Development Experience
===============================================

[](#configure-ide-for-smooth-development-experience)

5. Add `swoole` to Intelephense stubs
6. Make sure you have included the openswoole ide-helper  in the includePaths:

"intelephense.environment.includePaths": \[ "vendor/openswoole/ide-helper" \]

Important
=========

[](#important)

1. Do not close PHP tags in file if not using HTML
2. Use coroutines with caution - more testing needed to see if any data leak happens and validate SessionManager implementation

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance65

Regular maintenance activity

Popularity22

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

216d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5505362d0a6abe113dfdecb9a62db5f6a6b4efbea2f22b38db8d63187c217762?d=identicon)[sibidharan](/maintainers/sibidharan)

---

Top Contributors

[![sibidharan](https://avatars.githubusercontent.com/u/10979210?v=4)](https://github.com/sibidharan "sibidharan (6 commits)")[![wolf2627](https://avatars.githubusercontent.com/u/148734993?v=4)](https://github.com/wolf2627 "wolf2627 (4 commits)")[![hipraveenp](https://avatars.githubusercontent.com/u/31480959?v=4)](https://github.com/hipraveenp "hipraveenp (3 commits)")[![yuheswari](https://avatars.githubusercontent.com/u/147669281?v=4)](https://github.com/yuheswari "yuheswari (2 commits)")[![williyam-m](https://avatars.githubusercontent.com/u/146324543?v=4)](https://github.com/williyam-m "williyam-m (1 commits)")

---

Tags

httpphpasyncframeworkopenswoolezealphp

### Embed Badge

![Health badge](/badges/sibidharan-zealphp/health.svg)

```
[![Health](https://phpackages.com/badges/sibidharan-zealphp/health.svg)](https://phpackages.com/packages/sibidharan-zealphp)
```

###  Alternatives

[utopia-php/framework

A simple, light and advanced PHP HTTP framework

295618.4k9](/packages/utopia-php-framework)[dragon-code/support

Support package is a collection of helpers and tools for any project.

238.7M101](/packages/dragon-code-support)[utopia-php/http

A simple, light and advanced PHP HTTP framework

2962.8k2](/packages/utopia-php-http)[nimbly/limber

A super minimal HTTP framework that doesn't get in your way.

208.9k](/packages/nimbly-limber)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
