PHPackages                             rxcod9/php-swoole-crud-microservice - 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. [Admin Panels](/categories/admin)
4. /
5. rxcod9/php-swoole-crud-microservice

ActiveProject[Admin Panels](/categories/admin)

rxcod9/php-swoole-crud-microservice
===================================

PHP Swoole CRUD Microservice

v1.0.28(6mo ago)00[11 PRs](https://github.com/rxcod9/php-swoole-crud-microservice/pulls)MITPHPCI passing

Since Sep 14Pushed 1mo agoCompare

[ Source](https://github.com/rxcod9/php-swoole-crud-microservice)[ Packagist](https://packagist.org/packages/rxcod9/php-swoole-crud-microservice)[ Patreon](https://www.patreon.com/ramakant)[ RSS](/packages/rxcod9-php-swoole-crud-microservice/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (15)Versions (43)Used By (0)

PHP Swoole CRUD Microservice
============================

[](#php-swoole-crud-microservice)

A high-performance **PHP CRUD microservice** built with **Swoole**, featuring **MySQL**, **Redis**, **Prometheus**, **Grafana**, **Caddy**, and **Swagger UI** integration. Designed for **scalable**, **observable**, and **containerized** deployments.

By 🐼 [Ramakant Gangwar](https://github.com/rxcod9)

⚙️ Swagger / OpenAPI
====================

[](#️-swagger--openapi)

[![Swagger](docs/images/swagger.webp)](docs/images/swagger.webp)

⚡️ Performance
==============

[](#️-performance)

[![Performance](docs/images/performance.webp)](docs/images/performance.webp)

❤️ Health
=========

[](#️-health)

[![Performance](docs/images/health.webp)](docs/images/health.webp)

📊 Grafana Dashboards
====================

[](#-grafana-dashboards)

[![Grafana1](docs/images/grafana1.webp)](docs/images/grafana1.webp)[![Grafana2](docs/images/grafana2.webp)](docs/images/grafana2.webp)[![Grafana3](docs/images/grafana3.webp)](docs/images/grafana3.webp)

[![Latest Version](https://camo.githubusercontent.com/f0175e6d22f484b94f93e478b197d407a8c738740e4442c888fa9b1ce8a2924b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7278636f64392f7068702d73776f6f6c652d637275642d6d6963726f736572766963653f7374796c653d666c61742d737175617265)](https://github.com/rxcod9/php-swoole-crud-microservice/releases)[![GitHub Workflow Status](https://camo.githubusercontent.com/569b50a85ff8a69794035594b2da2244e8bd2f7bce16912f8d64853fa33794ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7278636f64392f7068702d73776f6f6c652d637275642d6d6963726f736572766963652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)](https://camo.githubusercontent.com/569b50a85ff8a69794035594b2da2244e8bd2f7bce16912f8d64853fa33794ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7278636f64392f7068702d73776f6f6c652d637275642d6d6963726f736572766963652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)[![Total Downloads](https://camo.githubusercontent.com/fe7651d7af82242533e9b4e42a95d1470f04fd1f7e980a26908536cb702dcb9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7278636f64392f7068702d73776f6f6c652d637275642d6d6963726f736572766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rxcod9/php-swoole-crud-microservice)

---

🚀 Features
----------

[](#-features)

- ⚡️ Fast HTTP server powered by **Swoole**
- 🗄️ MySQL database with **connection pooling**
- 🔁 Redis caching and pooling
- 📈 Prometheus metrics endpoint
- 📊 Grafana dashboards for monitoring
- 🔐 **Caddy** for HTTPS and reverse proxy
- 📘 Swagger UI for API documentation
- ❤️ Health checks for all services

---

🏁 Getting Started
-----------------

[](#-getting-started)

### 🧰 Prerequisites

[](#-prerequisites)

**Docker** &amp; **Docker Compose**

### 🐳 Docker Hub Quick Start

[](#-docker-hub-quick-start)

If you prefer using the pre-built Docker image, follow these steps:

```
# 1️⃣ Prepare environment file
# Copy the example .env file (you can modify it to match your setup)
cp .env.example .env
```

```
# Example .env values
APP_ENV=production
APP_DEBUG=false

DB_HOST=mysql
DB_PORT=3306
DB_USER=root
DB_PASS=secret
DB_NAME=app_db

REDIS_HOST=redis
REDIS_PORT=6379

PROMETHEUS_PORT=9502
SWOOLE_HTTP_PORT=9501
```

Now run the container:

```
# 🐙 Pull the latest image
docker pull rxcod9/php-swoole-crud-microservice:v1.0.24

# 🚀 Run the container with .env file
docker run --env-file .env -d -p 9501:9501 --name php-crud-microservice rxcod9/php-swoole-crud-microservice

# 🧩 Run database migrations inside the running container
docker exec -it php-crud-microservice php scripts/migrate.php
```

### 🧩 Docker Compose Usage

[](#-docker-compose-usage)

This repository includes a `docker-compose.yml` to run the full stack:

```
# ▶️ Start all services (PHP app, MySQL, Redis, Prometheus, Grafana, Caddy)
docker compose up -d --build

# ⏹️ Stop all services
docker compose down

# 📜 View logs
docker compose logs -f
```

Edit `.env` or `docker-compose.override.yml` to customize ports and database credentials.

### ⚡️ Quick Start

[](#️-quick-start)

```
# 📋 Copy example environment
cp .env.example .env

# 📦 Install PHP dependencies
composer install

# 🚀 Start all services in detached mode
docker compose up -d --build
```

### 🗄️ Database Migration

[](#️-database-migration)

```
# 🧭 Run migrations inside the app container
docker compose exec app php scripts/migrate.php
```

### 📘 API Documentation

[](#-api-documentation)

```
# 🧩 Generate OpenAPI spec
php bin/generate-swagger.php
```

Access Swagger UI at

---

🧠 Example API Usage
-------------------

[](#-example-api-usage)

```
# ➕ Create a user
curl -s -X POST http://localhost:9501/users     -H 'Content-Type: application/json'     -d '{"name":"alice","email":"alice@example.com"}'

# 📚 Get all users
curl -s -X GET http://localhost:9501/users -H 'Content-Type: application/json' | jq

# 🔍 Get a user by ID
curl -s -X GET http://localhost:9501/users/1 -H 'Content-Type: application/json' | jq

# 🔎 Get a user by email
curl -s -X GET http://localhost:9501/users/email/alice%40example.com -H 'Content-Type: application/json' | jq

# ✏️ Update a user
curl -i -X PUT http://localhost:9501/users/1     -H 'Content-Type: application/json'     -d '{"name":"alice-updated","email":"alice-updated@example.com"}'

# ❌ Delete a user
curl -i -X DELETE http://localhost:9501/users/1 -H 'Content-Type: application/json'
```

---

⚙️ Benchmarking
---------------

[](#️-benchmarking)

```
# 🧪 Using k6
k6 run --http-debug="full" k6 run k6/tests/crud_load_test.js > logs/k6.log 2>&1

# k6 command with all possible ENV variables
k6 run \
    -e BASE_URL=http://localhost:9501 \
    -e ENTITIES=users,items \
    -e CRUD=list,read,create,update \
    -e TOTAL_ENTITIES=200 \
    -e HOT_PERCENT=0.3 \
    -e COOL_PERCENT=0.3 \
    -e TOTAL_EXECUTIONS=2000 \
    -e MAX_VUS=50 \
    -e MAX_DURATION=10m \
    --http-debug="full" \
    tests/crud_main_test.js > logs/k6.log 2>&1

# 🧩 Using ApacheBench
ab -n 100000 -c 100 -v 4 http://localhost:9501/users/1 2>&1 | tee ab.log
```

---

📡 Monitoring
------------

[](#-monitoring)

- 📈 **Prometheus** scrapes metrics from the app, MySQL exporter and Redis Exporter.
- 📊 **Grafana** visualizes metrics (default port: `3000`).

---

⚙️ Environment Variables
------------------------

[](#️-environment-variables)

All configurable options are defined in `docker-compose.yml` and `.env.example`.

---

🧾 License
---------

[](#-license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance81

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.9% of commits — single point of failure

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

Every ~2 days

Total

29

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/95a00608fbd641680d1bbc969c8e820f4fbc1b72f2080fcbdb18c8c552857e2b?d=identicon)[rxcod9](/maintainers/rxcod9)

---

Top Contributors

[![rxcod9](https://avatars.githubusercontent.com/u/14928642?v=4)](https://github.com/rxcod9 "rxcod9 (161 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (51 commits)")

---

Tags

crudmicroservicemysqlphppoolswoole

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rxcod9-php-swoole-crud-microservice/health.svg)

```
[![Health](https://phpackages.com/badges/rxcod9-php-swoole-crud-microservice/health.svg)](https://phpackages.com/packages/rxcod9-php-swoole-crud-microservice)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sebastienheyd/boilerplate

Laravel Boilerplate based on AdminLTE 3 with blade components, user management, roles, permissions, logs viewer, ...

28618.2k3](/packages/sebastienheyd-boilerplate)[saithink/saiadmin

webman plugin

2709.9k1](/packages/saithink-saiadmin)[pimcore/admin-ui-classic-bundle

171.1M46](/packages/pimcore-admin-ui-classic-bundle)[doppar/framework

The Doppar Framework

366.7k8](/packages/doppar-framework)

PHPackages © 2026

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