PHPackages                             widget/widget - 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. widget/widget

ActiveLibrary[Framework](/categories/framework)

widget/widget
=============

A micro-framework provided powerful and simple APIs for faster and easier PHP development.

v0.18.4(1y ago)507514MITPHPPHP &gt;=7.2CI failing

Since Apr 15Pushed 1y ago6 watchersCompare

[ Source](https://github.com/twinh/wei)[ Packagist](https://packagist.org/packages/widget/widget)[ Docs](https://github.com/twinh/wei)[ RSS](/packages/widget-widget/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (89)Used By (0)

Wei
===

[](#wei)

[![Build Status](https://camo.githubusercontent.com/303ec9188bfcbc4417ba754fbe383f8b05fde21aec6434f976a0396c19d994e8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636865636b732d7374617475732f7477696e682f7765692f6d61696e3f7374796c653d666c61742d737175617265)](https://travis-ci.org/twinh/wei)[![Coverage Status](https://camo.githubusercontent.com/df6f1a741470b23929a0afe73dd6da312a7cb4c4432ae9ebecea015ae4d2af4a/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f7477696e682f7765692e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/twinh/wei)[![Latest Stable Version](https://camo.githubusercontent.com/14fc48442de7521c512b05443892c7dfe8be1f3aae336fafd1654140ff11f5d1/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7765692f7765692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wei/wei)[![License](https://camo.githubusercontent.com/30597ff9a350144f03bffdd9183e16468e0b3ca1193e1d08591d992622738d55/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://www.opensource.org/licenses/MIT)

Wei is a micro-framework provided powerful but simple APIs for faster and easier PHP development.

Getting started
---------------

[](#getting-started)

Start using Wei in 3 steps, it's easier than any frameworks you've seen before!

```
// 1. Include the wei container class
require 'path/to/wei/lib/Wei.php';

// 2. Create the default wei container instance
$wei = wei([
    // Options for wei container
    'wei' => [
        'debug' => true,
        // Other options ...
    ],
    // Options for database
    'db' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'dbname'    => 'wei',
        'charset'   => 'utf8',
        'user'      => 'root',
        'password'  => 'xxxxxx',
    ],
    // More options ...
]);

// 3. Using "db" object to execute SQL query
$result = $wei->db->fetch("SELECT 1 + 2");
```

Installation
------------

[](#installation)

### Composer

[](#composer)

Run the following command to install

```
composer require wei/wei
```

### Download source code

[](#download-source-code)

- [Stable Version](https://github.com/twinh/wei/releases/latest)
- [Develop Version](https://github.com/twinh/wei/archive/main.zip)

Resources
---------

[](#resources)

- [Documentation](docs/zh-CN) (Chinese, GitHub online markdown)
- [Documentation](http://twinh.github.io/wei/) (Chinese, single HTML file)
- [API Documentation](http://twinh.github.io/wei/apidoc/) (English)
- [Demo](demos) (English, GitHub online markdown)

API Overview
------------

[](#api-overview)

### Cache

[](#cache)

```
// Available cache objects
$wei->cache;
$wei->apcu;
$wei->arrayCache;
$wei->dbCache;
$wei->fileCache;
$wei->memcache;
$wei->memcached;
$wei->mongoCache;
$wei->redis;
$wei->nullCache;

$cache = $wei->memcached;

// Cache APIs
$cache->get('key');
$cache->set('key', 'value', 60);
$cache->delete('key');
$cache->has('key');
$cache->add('key', 'value');
$cache->replace('key', 'value');
$cache->incr('key', 1);
$cache->decr('key', 1);
$cache->getMultiple(array('key', 'key2'));
$cache->setMultiple(array('key' => 'value', 'key2' => 'value2'));
$cache->clear();

// ...
```

### Database

[](#database)

```
$db = $wei->db;

// Basic CRUD and Active Recrod support
$db->query();
$db->insert();
$db->update();
$db->delete();
$db->select();
$db->selectAll();
$db->fetch();
$db->fetchAll();
$db->fetchColumn();
$db->find();
$db->findOne();
$db->findAll();
$db->execute();

// Using query builder to build SQL
$record = $db('table');

$record
    ->select()
    ->addSelect()
    ->update()
    ->delete()
    ->from()
    ->where()
    ->andWhere()
    ->orWhere()
    ->groupBy()
    ->addGroupBy()
    ->having()
    ->andHaving()
    ->orHaving()
    ->orderBy()
    ->addOrderBy()
    ->offset()
    ->limit()
    ->page()
    ->indexBy();

$record->find();
$record->findAll();
$record->fetch();
$record->fetchAll();
$record->fetchColumn();
$record->count();
$record->execute();
$record->getSql();

// ...
```

### Validator

[](#validator)

```
// Available validator objects

// Data type and composition
$wei->isAlnum($input);
$wei->isAlpha($input);
$wei->isBlank($input);
$wei->isDecimal($input);
$wei->isDigit($input);
$wei->isDivisibleBy($input);
$wei->isDoubleByte($input);
$wei->isEmpty($input);
$wei->isEndsWith($input);
$wei->isIn($input);
$wei->isLowercase($input);
$wei->isNull($input);
$wei->isNumber($input);
$wei->isRegex($input);
$wei->isRequired($input);
$wei->isStartsWith($input);
$wei->isType($input);
$wei->isUppercase($input);

// Length
$wei->isLength($input);
$wei->isCharLength($input);
$wei->isMaxLength($input);
$wei->isMinLength($input);

// Comparison
$wei->isEqualTo($input);
$wei->isIdenticalTo($input);
$wei->isGreaterThan($input);
$wei->isGreaterThanOrEqual($input);
$wei->isLessThan($input);
$wei->isLessThanOrEqual($input);
$wei->isBetween($input);

// Date and time
$wei->isDate($input);
$wei->isDateTime($input);
$wei->isTime($input);

// File and directory
$wei->isDir($input);
$wei->isExists($input);
$wei->isFile($input);
$wei->isImage($input);

// Network
$wei->isEmail($input);
$wei->isIp($input);
$wei->isTld($input);
$wei->isUrl($input);
$wei->isUuid($input);

// Region: All
$wei->isCreditCard($input);

// Region: Chinese
$wei->isChinese($input);
$wei->isIdCardCn($input);
$wei->isIdCardHk($input);
$wei->isIdCardMo($input);
$wei->isIdCardTw($input);
$wei->isPhoneCn($input);
$wei->isPostcodeCn($input);
$wei->isQQ($input);
$wei->isMobileCn($input);

// Group
$wei->isAllOf($input);
$wei->isNoneOf($input);
$wei->isOneOf($input);
$wei->isSomeOf($input);

// Others
$wei->isAll($input);
$wei->isCallback($input);
$wei->isColor($input);

// Validate and get error message
if (!$wei->isDigit('abc')) {
    print_r($wei->isDigit->getMessages());
}

// ...
```

### [More](docs/zh-CN#api)

[](#more)

```
$wei->request;
$wei->cookie;
$wei->session;
$wei->ua;
$wei->upload;
$wei->response;
$wei->e;
$wei->logger;
$wei->call;
$wei->env;
$wei->error;

// ...
```

Testing
-------

[](#testing)

To run the tests:

```
$ phpunit
```

License
-------

[](#license)

Wei is an open-source project released MIT license. See the LICENSE file for details.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance49

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

Every ~51 days

Recently: every ~38 days

Total

87

Last Release

374d ago

PHP version history (4 changes)0.9.2-betaPHP &gt;=5.3.0

0.9.9-RC1PHP &gt;=5.3.3

0.9.10PHP &gt;=5.3.4

v0.9.24PHP &gt;=7.2

### Community

Maintainers

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

---

Top Contributors

[![twinh](https://avatars.githubusercontent.com/u/594436?v=4)](https://github.com/twinh "twinh (6345 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (60 commits)")[![JMSBot](https://avatars.githubusercontent.com/u/1719218?v=4)](https://github.com/JMSBot "JMSBot (16 commits)")[![gbzhurui](https://avatars.githubusercontent.com/u/13092668?v=4)](https://github.com/gbzhurui "gbzhurui (2 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

cachedatabasephpframeworkvalidatordatabasecache

### Embed Badge

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

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

###  Alternatives

[wei/wei

A micro-framework provided powerful and simple APIs for faster and easier PHP development.

5398.9k4](/packages/wei-wei)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[utopia-php/cache

A simple cache library to manage application cache storing, loading and purging

31379.3k8](/packages/utopia-php-cache)[yiisoft/cache-redis

Yii Caching Library - Redis Handler

1012.9k](/packages/yiisoft-cache-redis)

PHPackages © 2026

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