cloverphp/clover

Clover PHP: a modern, unopinionated, and lightweight framework.

v0.0.1 2025-09-29 14:22 UTC

This package is auto-updated.

Last update: 2025-10-03 04:15:52 UTC


README

Clover PHP is a modern, unopinionated, and lightweight Express.js-style framework for PHP 8.4. It helps you build REST APIs, web apps, and microservices with the simplicity of Express.js and the power of modern PHP.

Code Coverage CodeQL Tests Packagist Version Packagist Dependency Version Packagist License Packagist Downloads Packagist Stars

✨ Features

🚀 Minimal & Fast – Simple API design, inspired by Express.js.

⚡ Async Support – Built with PHP Fibers & AMPHP for non-blocking I/O.

🗂️ Routing System – Intuitive get(), post(), etc., with async router support.

🔑 Auth Ready – Supports sessions, cookies, and JWT-based authentication.

🧩 Extensible Middleware – Add global and route-level middleware for logging, security, and validation.

💾 Database Agnostic – Works with both SQL and NoSQL databases.(Upcoming)

🛠️ MVC Support – Controllers, models, and views with interfaces for clean architecture.

🛡️ Error Handling & Logging – Developer-friendly error responses and logging tools.

🎨 Unopinionated – Flexible enough for small apps or large enterprise projects.

📦 Composer & PSR-12 – Modern PHP practices with full Composer/PSR-12 compliance.

📦 Installation

composer create-project cloverphp/clover my-app
cd my-app
php -S localhost:3000 -t public

🚀 Quick Start

<?php

require_once __DIR__ . "/vendor/autoload.php";

use Clover\Clover;
use Clover\Http\Request;
use Clover\Http\Response;

$app = new Clover();
$router = $app->router();

// Home route
$router->get("/", fn(Request $req, Response $res) =>
$res->send("<h1>Welcome to 🍀 Clover PHP!</h1>"));

$router->post("/", fn(Request $req, Response $res) =>
    $res->json(['name' => 'Clover PHP!'])
);

$app->run(3000, true);

📂 Project Structure

my-app/
├── app/
│   ├── Controllers/
│   ├── Models/
│   └── Views/
├── public/
│   └── index.php
├── vendor/
├── composer.json
└── README.md

🔑 Example Middleware

$app->use(function (Request $req, Response $res, callable $next) {
    $res->setHeader("X-Powered-By", "Clover PHP");
    $next($req, $res);
});

🛡️ License

Clover PHP is open-sourced software licensed under the Packagist License