cloverphp / clover
Clover PHP: a modern, unopinionated, and lightweight framework.
Fund package maintenance!
CodeWithSushil
Open Collective
Buy Me A Coffee
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 1
Type:project
Requires
- php: ^8.2
- cloverphp/framework: ^0.0.2
Requires (Dev)
- fakerphp/faker: ^1.24
- laravel/pint: ^1.25
- mockery/mockery: ^1.6
- phpunit/phpunit: ^12.3
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.
✨ 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); });