PHPackages                             sinri/clover - 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. sinri/clover

Abandoned → [sinri/enoch](/?search=sinri%2Fenoch)Library

sinri/clover
============

An MVC Framework for Restful Web Project in PHP.

0.2(9y ago)011MITPHPPHP &gt;=5.3.0

Since Dec 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/sinri/Clover)[ Packagist](https://packagist.org/packages/sinri/clover)[ Docs](https://github.com/sinri/Clover)[ RSS](/packages/sinri-clover/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Clover
======

[](#clover)

An MVC Framework for Restful Web Project in PHP, under MIT License, now version 0.2.

Introduction
------------

[](#introduction)

Clover is designed after CodeIgniter but much more simpler. It provides Restful style HTTP request process resolution.

Clover uses Model-View-Controller (MVC) architecture. Clover would parse all requests to controller, method and its parameters, and call the very method of controller with those parameters to response.

In short, URL `clover.ng/CONTROLLER/METHOD/Param1/Param2` would be processed by `CONTROLLER()->METHOD(Param1,Param2)`. Of course, URL `clover.ng/CONTROLLER/METHOD/Param1`, `clover.ng/CONTROLLER/METHOD`, and `clover.ng/CONTROLLER` are also available if controller was designed to support.

For `GET` request, Clover would parse the query string. For `POST`, Clover accept encoded url data and form data format by default, and also request with JSON data as HTTP request body when declare `application/json` as the value of Header `Content-Type`.

Install
-------

[](#install)

Clover is based on rewrite modual of Apache. (Nginx is also supported, in theory.) Create and edit `.htaccess` file in the root directory with the following:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
# For Apache2

```

Usage
-----

[](#usage)

Clover supports processing web requests. As well, Clover could be used in CLI mode since version 0.2, as Yii Framework supports.

Just fill the controller classes in `controller` directory, model classes in `model` directory, and view html files in `view` directory. For command line use, fill commands in `command` directory.

Import Clover file into `index.php` for web request, or `CloverCLI.php` for CLI:

```
require __DIR__.'/core/Clover.php';

```

In `index.php`, first set the root path:

```
Clover::setRootPath($path_of_root);

```

For some strange purposes, Clover supports customization on MVC directories, just modify the source code under MIT License.

Finally, start Clover:

```
Clover::start();

```

### Controller

[](#controller)

Create an php file with a class inside. File name should be the same with the class inside. The class should extend class `CloverController`.

The methods of the class would be the method of the controller and `index` would be the default. The third element and the next ones of the url, if exist, would be the parameters of the method.

Use method `display($view_file,$assignment=array(),$isPart=false)` to display with certain view. The second parameter is an array to carry the assigned parameters to view. For example, if pass `array('K'=>'V')` as `$assignment`, you can use `` to display `V` in your response view. The third parameter accepts boolean value and FALSE by default to stop PHP script with this very function call. If TRUE were given, the PHP script would run continuely until the end of the code.

### Model

[](#model)

You can define model class in model directory in the php file with same name, which would be loaded automatically when called.

### View

[](#view)

For view, create html file in view directory. Within the html content, you can use PHP codes inside, as well as the assigned parameters.

### Command

[](#command)

Create an php file with a class inside. File name should be the same with the class inside. The class should extend class `CloverCommand`.

The methods of the class which named as `.+Action` would be treated as action to execute, and default as `defaultAction`. For parameter usage, use `--PARAM_NAME=PARAM_VALUE`.

You can override `beforeAction` and `afterAction` functions to realize the action procedure control.

Clover Class Toolkits
---------------------

[](#clover-class-toolkits)

The following are all static functions of Clover class.

### Get Query Method

[](#get-query-method)

```
function getQuery($name=null,$default=null)

```

Return the whole `$_GET` when `$name` is null. When `$name` is not null, try to return `$_GET[$name]` if it is set, or `$default` would be returned.

### Get Raw HTTP Request Method

[](#get-raw-http-request-method)

```
function getRawRequestBody()

```

Return the raw body of the current HTTP request.

### Get Data Method

[](#get-data-method)

```
function getData($name=null,$default=null)

```

If request comes in standard HTTP format, return the whole `$_POST` when `$name` is null. When `$name` is not null, try to return `$_POST[$name]` if it is set, or `$default` would be returned.

If request comes in JSON Object format and `application/json` delared in `Content-Type` header, Clover would parse the HTTP request to JSON Object and get its property with the name given, or return `$default` when not set.

P.S.
----

[](#ps)

I think that, CI is in good design, but it is too heavy for simple project. I want make an environment to work with free feel, from both requirements and frameworks. In short, I do not want to learn too much about a tool and then trap into the tool. Using Clover, you can get the nearly same result with CI, but you can use all pure PHP function instead of the completely capsulized toolkit of CI. You like extension? Well, just develop them as you like. Clover is only a base framework.

###  Health Score

22

—

LowBetter than 24% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3382d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f21c380187798de639192557cfc054683355c6f8c1649cff213fee795590831?d=identicon)[sinri](/maintainers/sinri)

---

Top Contributors

[![sinri](https://avatars.githubusercontent.com/u/5821330?v=4)](https://github.com/sinri "sinri (9 commits)")

---

Tags

mvcrestful

### Embed Badge

![Health badge](/badges/sinri-clover/health.svg)

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

###  Alternatives

[aplus/mvc

Aplus Framework MVC Library

2611.6M3](/packages/aplus-mvc)[laminas/laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins

17223.8M343](/packages/laminas-laminas-mvc)

PHPackages © 2026

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