PHPackages                             spinxphp/framework - 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. spinxphp/framework

ActiveLibrary[Framework](/categories/framework)

spinxphp/framework
==================

A fast, lightweight PHP framework with enforced DDD architecture — flexible across persistent-process runtimes (RoadRunner, Swoole) without being tied to either.

v1.0.14(today)025↑2660%MITPHPPHP &gt;=8.2CI passing

Since Aug 25Pushed todayCompare

[ Source](https://github.com/iamdevroyal/spinxphp)[ Packagist](https://packagist.org/packages/spinxphp/framework)[ Docs](https://spinxphp.pages.dev)[ RSS](/packages/spinxphp-framework/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (21)Versions (16)Used By (0)

Spinx Framework
===============

[](#spinx-framework)

**The Modern High-Performance PHP Framework for Persistent Workers, Enforced DDD Architecture, and Reactive Island Hydration.**

[![Latest Version](https://camo.githubusercontent.com/c2794c568fadcde252ebd7421035d3617187db07a8c2d465b17f5a5670cc7e57/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d76312e302e31342d3633363666312e7376673f7374796c653d666c61742d737175617265)](https://github.com/iamdevroyal/spinxphp)[![Documentation](https://camo.githubusercontent.com/daf5130736a9507754c6ed10d7abb79b7bee2e5042d984bbd45448b7fc3de2e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d7370696e787068702e70616765732e646576253246646f63732d6563343839392e7376673f7374796c653d666c61742d737175617265)](https://spinxphp.pages.dev/docs)[![PHP Version](https://camo.githubusercontent.com/a72b707edbcc5799d0f1c8117fbde294008e4549222c985ab58bab67dfb350a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d3862356366362e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/f2bb90ceda2a31e3b7c745e42e0ac4a63d0dcd8b9465a282a0764e07f0fb6d7e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3932253246393225323070617373696e672d3130623938312e7376673f7374796c653d666c61742d737175617265)](https://github.com/iamdevroyal/spinxphp)

---

⚡ Why Spinx?
------------

[](#-why-spinx)

Traditional PHP frameworks run on PHP-FPM, destroying and recreating the application lifecycle on every incoming HTTP request. Spinx runs inside **long-lived persistent execution workers** (RoadRunner by default, Swoole coroutines opt-in). Route compilation, dependency injection reflection, configuration parsing, and database schemas remain warmed in RAM across requests — delivering **sub-millisecond latencies and massive throughput**.

### Core Pillars

[](#core-pillars)

- 🚀 **Extreme Persistent-Worker Performance**: Powered by a unified `ServerAdapter` contract with zero per-request bootstrap cost.
- 🏗️ **Kernel-Enforced DDD Architecture**: Code must live within structured Domain-Driven Design modules (`app/Modules//module.php`). Loose files in global folders are rejected at boot.
- 🛡️ **Zero-Leak Memory Safety**: `RequestScope` container resets and custom PHPStan static analysis rules eliminate cross-request memory contamination.
- ⚡ **Fluent Route DSL &amp; Alias Registry**: Clean, expressive routing with automatic DI autowiring.
- 🔐 **State-Safe Auth &amp; Sessions**: Integrated request-isolated session drivers (File &amp; Database) and bcrypt authentication.
- 🗄️ **DBAL 4 Active Record ORM &amp; Schema Cache**: Compiled ahead-of-time schema column caching, selective column querying (`selectWithout`), conditional query chaining (`when/then/else`), platform-aware `upsert`, and transaction row locking (`atomic`).
- ⏱️ **In-Framework Task Scheduler**: Fluent cron scheduling in `schedule.php` executed via a single `spinx schedule:run` command.
- 📖 **OpenAPI 3.1 Generator**: Auto-generate OpenAPI schemas via route reflection and PHP 8 attributes.
- 🏝️ **Reactive Island Hydration**: Server-rendered HTML views with targeted client-side component hydration (`@island`) for Vue 3 and React 19.
- 📱 **Mobile Preview &amp; Native Shells**: Interactive browser-based mobile preview container (`spinx preview --mobile`) and native Android (Kotlin) / iOS (Swift) shell generators.

---

📦 Installation &amp; Quickstart
-------------------------------

[](#-installation--quickstart)

Create a new Spinx project with a single command:

```
# 1. Create a new Spinx application
spinx new my-app --frontend=vue

# 2. Enter project directory
cd my-app

# 3. Boot backend persistent server + Vite HMR dev server
spinx serve
```

### System Requirements

[](#system-requirements)

- **PHP**: `>= 8.2` (uses typed properties, readonly classes, and enums)
- **Extensions**: `ext-mbstring`, `ext-pdo` (or `pdo_sqlite` / `pdo_mysql` / `pdo_pgsql`)
- **Node.js**: `>= 18.0` (for Vite frontend asset pipeline)

---

🧩 Enforced DDD Module Architecture
----------------------------------

[](#-enforced-ddd-module-architecture)

Spinx eliminates messy global folders by enforcing Domain-Driven Design (DDD) boundaries at the kernel level.

```
spinx make:module Billing
```

This scaffolds the following structured architecture:

```
app/Modules/Billing/
├── Domain/
│   ├── Entities/            (pure domain logic, zero infrastructure dependencies)
│   ├── ValueObjects/
│   ├── Events/
│   └── Repositories/        (interfaces only)
├── Application/
│   ├── Services/            (use-case orchestration)
│   └── Jobs/                (queueable asynchronous tasks)
├── Infrastructure/
│   ├── Repositories/        (concrete DBAL repository implementations)
│   ├── Http/
│   │   ├── Controllers/     (invokable HTTP controllers)
│   │   └── Middleware/      (request middlewares)
│   └── Persistence/
│       ├── Models/          (Active Record models)
│       └── Migrations/      (timestamped schema migrations)
└── module.php               (declarative routes, aliases, and DI container wiring)

```

---

🚦 Fluent Routing DSL &amp; Alias Registry
-----------------------------------------

[](#-fluent-routing-dsl--alias-registry)

Declare your module's controllers, middlewares, routes, and services cleanly inside `app/Modules//module.php`:

```
use App\Modules\Billing\Infrastructure\Http\Controllers\InvoiceController;
use Spinx\Auth\Middleware\AuthMiddleware;
use Spinx\Routing\{AliasRegistry, Route, RouteBuilder};
use Symfony\Component\DependencyInjection\ContainerBuilder;

return [
    // Register controller aliases (auto-wired into Symfony DI container):
    'controllers' => static function (AliasRegistry $r): void {
        $r->registerController('invoice_show', InvoiceController::class);
    },

    // Register middleware aliases:
    'middlewares' => static function (AliasRegistry $r): void {
        $r->registerMiddleware('auth', AuthMiddleware::class);
    },

    // Define routes using fluent DSL:
    'routes' => static function (RouteBuilder $routes): void {
        Route::get(['invoices.show', '/invoices/{id}'])
            ->middleware(['auth'])
            ->controller('invoice_show');

        Route::group('/api/v1', function (RouteBuilder $group): void {
            Route::post(['invoices.create', '/invoices'])->controller('invoice_create');
        });
    },

    // Register module services into Symfony DI:
    'services' => static function (ContainerBuilder $container, string $moduleDir): void {
        $container->register(InvoiceRepositoryInterface::class, InvoiceRepository::class)
            ->setAutowired(true)
            ->setPublic(true);
    },
];
```

---

🗄️ Database &amp; Active Record ORM
-----------------------------------

[](#️-database--active-record-orm)

Spinx ORM is built on top of Doctrine DBAL 4, providing familiar active-record ergonomics with persistent-worker performance.

```
namespace App\Modules\Billing\Infrastructure\Persistence\Models;

use Spinx\Database\Model;

final class Invoice extends Model
{
    protected static string $table = 'invoices';
    protected array $fillable = ['customer_id', 'amount', 'status'];
    protected array $casts = ['amount' => 'float'];
}
```

### Pre-Compiled Schema Cache (`spinx schema:compile`)

[](#pre-compiled-schema-cache-spinx-schemacompile)

Introspect tables ahead of time and load column mappings directly into OpCache:

```
spinx schema:compile
```

### Advanced Querying

[](#advanced-querying)

```
use App\Modules\Billing\Infrastructure\Persistence\Models\Invoice;
use Spinx\Database\DB;

// 1. Column filtering backed by pre-compiled SchemaCache:
$invoices = Invoice::query()
    ->selectWith('id', 'amount', 'status')
    ->get();

$users = User::query()
    ->selectWithout('password', 'remember_token')
    ->get();

// 2. Conditional query builder (when / then / else / otherwise):
$results = Invoice::query()
    ->where('status', 'active')
    ->when($isAdmin)
        ->then(fn($q) => $q->where('include_internal', true))
        ->else(fn($q) => $q->where('is_public', true))
    ->get();

// 3. Platform-aware atomic upsert:
Invoice::upsert(
    values: ['id' => 101, 'amount' => 450.00, 'status' => 'paid'],
    uniqueColumns: ['id'],
    updateColumns: ['amount', 'status']
);

// 4. Row locking inside transactions (SELECT FOR UPDATE):
Invoice::atomic($invoiceId, function (Invoice $invoice): void {
    $invoice->update(['status' => 'settled']);
});

// 5. DB Static Façade for transactions:
DB::transaction(function ($conn): void {
    DB::statement('UPDATE accounts SET balance = balance - 100 WHERE id = :id', ['id' => 1]);
    DB::statement('UPDATE accounts SET balance = balance + 100 WHERE id = :id', ['id' => 2]);
});
```

---

🔒 Authentication &amp; Session Subsystem
----------------------------------------

[](#-authentication--session-subsystem)

Designed specifically to prevent memory leaks and session fixation attacks in persistent runtimes:

```
use Spinx\Auth\{Auth, Hash};

// 1. Bcrypt Password Hashing:
$hashed = Hash::make('secret_password', cost: 12);
$isValid = Hash::check('secret_password', $hashed);

// 2. Attempt Login (auto-regenerates session ID for fixation protection):
if (Auth::attempt(['email' => $email, 'password' => $password])) {
    $user = Auth::user();
    $userId = Auth::id();
}

// 3. Check State & Logout:
if (Auth::check()) {
    // User is logged in
}

Auth::logout();
```

---

🧪 Data Validation Engine
------------------------

[](#-data-validation-engine)

```
use Spinx\Validation\Validator;

$validated = Validator::make($request->request->all(), [
    'name'     => 'required|string|max:100',
    'email'    => 'required|email',
    'password' => 'required|min:8|confirmed',
    'tier'     => 'required|in:free,pro,enterprise',
    'bio'      => 'nullable|string|max:500',
])->validate(); // Returns strictly allowed attributes; drops extraneous keys
```

---

⏱️ In-Framework Task Scheduler
------------------------------

[](#️-in-framework-task-scheduler)

Define cron jobs fluently in `schedule.php`:

```
use Spinx\Schedule\Scheduler;

return function (Scheduler $scheduler, $container): void {
    // Run daily at 03:00 AM:
    $scheduler->call(function () use ($container) {
        $container->get(CleanupService::class)->run();
    }, 'daily cleanup')->daily('03:00');

    // Run every 15 minutes:
    $scheduler->call(fn() => syncInventory(), 'inventory sync')->everyMinutes(15);

    // Run every Monday at 08:30:
    $scheduler->call(fn() => sendWeeklyReport(), 'weekly report')->weekly(1, '08:30');
};
```

Run due tasks via one OS cron entry:

```
* * * * * cd /path/to/app && php spinx schedule:run >> /dev/null 2>&1
```

---

📖 OpenAPI 3.1 Spec Generator
----------------------------

[](#-openapi-31-spec-generator)

Annotate your controllers with native PHP 8 attributes:

```
namespace App\Modules\Billing\Infrastructure\Http\Controllers;

use Spinx\OpenApi\Attributes\{ApiSummary, ApiParam, ApiResponse, ApiTag};
use Symfony\Component\HttpFoundation\{Request, JsonResponse};

#[ApiTag('Invoices')]
#[ApiSummary('Retrieve invoice details')]
#[ApiParam(name: 'id', in: 'path', type: 'integer', description: 'Invoice ID')]
#[ApiResponse(status: 200, description: 'Invoice data returned')]
#[ApiResponse(status: 404, description: 'Invoice not found')]
final class InvoiceShowController
{
    public function __invoke(Request $request, int $id): JsonResponse
    {
        return new JsonResponse(['id' => $id, 'status' => 'paid']);
    }
}
```

Generate the OpenAPI 3.1 JSON schema:

```
spinx openapi:generate --output=public/openapi.json
```

---

🏝️ Reactive Island Hydration
----------------------------

[](#️-reactive-island-hydration)

Server-render your HTML views with ultra-fast native templates and selectively hydrate Vue 3 or React 19 components on the client:

```

    Project Metrics
    Server rendered timestamp: {{ date('Y-m-d H:i') }}

    @island('MetricsChart', ['projectId' => $project->id])

```

---

📱 Mobile Device Preview Tool
----------------------------

[](#-mobile-device-preview-tool)

Spinx includes a built-in browser-based interactive mobile device container for testing responsive views across simulated iPhone and Android viewports:

```
spinx preview --mobile
```

To scaffold native WebView shells:

```
# Android shell (Kotlin + WebView):
spinx build:mobile --android

# iOS shell (Swift + WKWebView):
spinx build:mobile --ios
```

---

🛠️ Complete CLI Command Reference
---------------------------------

[](#️-complete-cli-command-reference)

CommandDescription`spinx new `Scaffold a brand new Spinx project`spinx serve`Boot backend server (RoadRunner/Swoole) + Vite dev server (HMR)`spinx driver:swap `Switch runtime driver (`roadrunner` or `swoole`)`spinx make:module `Scaffold a complete DDD module skeleton`spinx make:controller  `Generate controller in module Infrastructure layer`spinx make:entity  `Generate Domain entity`spinx make:service  `Generate Application service`spinx make:repository  `Generate repository interface &amp; implementation`spinx make:model  `Generate ORM model in Infrastructure layer`spinx make:middleware  `Generate middleware class`spinx make:migration  `Generate timestamped database migration`spinx make:mail  `Generate Mailable + view + queueable Job`spinx migrate [Name]`Run pending database migrations`spinx module:migrate `Run pending migrations for one module`spinx schema:compile`Compile schema into `storage/cache/schema_columns.php``spinx queue:work`Poll and process database-backed job queue`spinx schedule:run`Run all tasks in `schedule.php` due right now`spinx openapi:generate`Generate OpenAPI 3.1 specification schema`spinx preview --mobile`Open browser-based interactive mobile device container`spinx preview --android`Open dev server on connected Android device/emulator`spinx preview --ios`Open dev server on iOS Simulator (macOS + Xcode)`spinx preview --desktop`Open dev server in native desktop webview window`spinx build:mobile --android`Scaffold native Android shell in `mobile/android/``spinx build:mobile --ios`Scaffold native iOS shell in `mobile/ios/``spinx build`Production build: compiled assets + primed backend cache---

🧪 Testing &amp; Verification
----------------------------

[](#-testing--verification)

Run the test suite across all subsystems:

```
php tests/Integration/KernelIntegrationTest.php
```

All 92 integration assertions across Validation, Scheduler, Auth, Sessions, Routing DSL, and DBAL QueryBuilder pass with 100% success rate.

---

📄 License
---------

[](#-license)

Spinx is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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 ~0 days

Total

15

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104790252?v=4)[Njoku Royal Nnaemeka](/maintainers/iamdevroyal)[@iamdevroyal](https://github.com/iamdevroyal)

---

Tags

phpframeworkopenapiswooleroadrunnerDomain Driven DesigndddreactCoroutinesvuespinxislandspersistent-workers

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spinxphp-framework/health.svg)

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

###  Alternatives

[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M684](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1301.7M3.1k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M236](/packages/sulu-sulu)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M780](/packages/sylius-sylius)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)

PHPackages © 2026

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