PHPackages                             reactphp-x/reactphp-x - 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. reactphp-x/reactphp-x

ActiveProject

reactphp-x/reactphp-x
=====================

Laravel-like project skeleton using ReactPHP-X (routes, logging, database)

18PHP

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/reactphp-x/reactphp-x)[ Packagist](https://packagist.org/packages/reactphp-x/reactphp-x)[ RSS](/packages/reactphp-x-reactphp-x/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

ReactPHP-X Project Skeleton
---------------------------

[](#reactphp-x-project-skeleton)

A Laravel-like project structure built on ReactPHP-X, featuring routing, logging, and async database access. Uses Laravel's container and supports controller@method routes.

### Features

[](#features)

- **Routes**: Controller@method via `reactphp-x/route`.
- **Config**: `config/*.php` with `config()` helper.
- **Env**: `.env` via `vlucas/phpdotenv`.
- **Logging**: Channel-based config, single filesystem adapter.
- **Database**: Async MySQL using Cycle via `reactphp-x/cycle-database`.
- **ORM**: Cycle ORM with annotated entities and migrations support.

### Requirements

[](#requirements)

- PHP &gt;= 8.1

### Quick Start

[](#quick-start)

```
composer install
cp .env.example .env
composer start
# visit http://127.0.0.1:8080/api/hello
```

### Commands

[](#commands)

```
# Simple hello command
composer hello

# Database operations example (SELECT, INSERT, UPDATE, DELETE, UPSERT)
# Before running, import the table structure:
# mysql -u root -p your_database < app/Commands/database-example.sql
composer db-example

# ORM example
php app/Commands/orm-example.php

# Database migrations
php app/Commands/migrations.php [action]
# Actions: list, status, run, rollback
```

### Directory Structure

[](#directory-structure)

```
app/
  Commands/
  Http/Controllers/
  Models/          # ORM entities
  Repositories/    # Custom repositories
bootstrap/
  app.php
  helpers.php
config/
  app.php
  logging.php
  database.php
migrations/        # Database migrations
public/
  index.php
routes/
  api.php
storage/
  logs/
vendor/

```

### Configuration

[](#configuration)

- `config/app.php`: app name, env, debug, timezone, listen address
- `config/logging.php`: channels and defaults
- `config/database.php`: async MySQL connection and pool

Helpers:

```
// Config helper
config('app.listen');

// Database helpers
db()->query('SELECT * FROM users')->fetchAll();
table('users')->where('id', 1)->fetchAll();
table('users')->insert()->values($data)->run();
table('users')->update($data, ['id' => 1])->run();
table('users')->upsert()->conflicts(['email'])->values($data)->updates($fields)->run();

// ORM helper
orm()->getRepository(User::class)->findByPK(1);
orm()->getRepository(User::class)->findAll([]);
```

### Routing

[](#routing)

Defined in `routes/api.php` using controller@method syntax.

```
// routes/api.php
$route->group('/api', function (\ReactphpX\Route\Route $route) {
    $route->get('/hello', \App\Http\Controllers\HelloController::class . '@index');
});
```

Example controller:

```
namespace App\Http\Controllers;

use Psr\Http\Message\ServerRequestInterface as Request;
use React\Http\Message\Response;

class HelloController
{
    public function index(Request $request)
    {
        return new Response(200, ['Content-Type' => 'application/json'], json_encode(['message' => 'Hello, API!']));
    }
}
```

### HTTP Entry

[](#http-entry)

`public/index.php` wires the router and reads listen address from `config('app.listen')`.

### ORM (Cycle ORM)

[](#orm-cycle-orm)

This project uses Cycle ORM with PHP 8 attributes for entity definitions.

#### Entity Definition

[](#entity-definition)

Define entities in `app/Models/` using PHP 8 attributes:

```
namespace App\Models;

use Cycle\Annotated\Annotation as Cycle;

#[Cycle\Entity(table: 'users', repository: \App\Repositories\UserRepository::class)]
class User
{
    #[Cycle\Column(type: 'primary')]
    public int $id;

    #[Cycle\Column(type: 'string')]
    public string $name;

    #[Cycle\Column(type: 'smallInteger')]
    public int $status = 0;

    #[Cycle\Column(type: 'string', nullable: true)]
    public ?string $avatar = null;

    #[Cycle\Column(type: 'datetime', nullable: true)]
    public ?\DateTimeInterface $createdAt = null;

    #[Cycle\Column(type: 'datetime', nullable: true)]
    public ?\DateTimeInterface $updatedAt = null;
}
```

#### Custom Repository

[](#custom-repository)

Create custom repositories in `app/Repositories/`:

```
namespace App\Repositories;

class UserRepository extends \Cycle\ORM\Select\Repository
{
    public function withActive(): self
    {
        $repository = clone $this;
        $repository->select->where('status', 1);
        return $repository;
    }
}
```

#### Usage Examples

[](#usage-examples)

```
use App\Models\User;

// Get repository
$repository = orm()->getRepository(User::class);

// Find by primary key
$user = $repository->findByPK(1);

// Find all with custom scope
$activeUsers = $repository->withActive()->findAll([]);

// Find all
$users = $repository->findAll([]);
```

#### Migrations

[](#migrations)

Manage database migrations:

```
# List migrations
php app/Commands/migrations.php list

# Run pending migrations
php app/Commands/migrations.php run

# Rollback last migration
php app/Commands/migrations.php rollback
```

Migration files are stored in `migrations/` directory with format: `YYYYMMDD.HHMMSS_0_0_default_description.php`

### Filesystem &amp; Logging

[](#filesystem--logging)

- Filesystem adapter is a container singleton `fs`.
- Logging configuration is loaded from `config/logging.php` and uses that adapter across channels.

### Environment

[](#environment)

Copy `.env.example` to `.env` and adjust:

```
APP_NAME, APP_ENV, APP_DEBUG, APP_TIMEZONE, LOG_LEVEL, X_LISTEN
DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_CHARSET
DB_POOL_MIN, DB_POOL_MAX, DB_POOL_QUEUE, DB_POOL_TIMEOUT

```

### Reference

[](#reference)

- Routing package: [reactphp-x/route](https://github.com/reactphp-x/route)

### License

[](#license)

MIT

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance60

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76907477?v=4)[wpjscc](/maintainers/wpjscc)[@wpjscc](https://github.com/wpjscc)

---

Top Contributors

[![wpjscc](https://avatars.githubusercontent.com/u/76907477?v=4)](https://github.com/wpjscc "wpjscc (13 commits)")

### Embed Badge

![Health badge](/badges/reactphp-x-reactphp-x/health.svg)

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

PHPackages © 2026

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