PHPackages                             hisune/tinymvc - 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. hisune/tinymvc

ActiveLibrary[Framework](/categories/framework)

hisune/tinymvc
==============

The Tiny MVC Framework Libraries

1.6(10y ago)71123261MITPHPPHP &gt;=5.3.0

Since Jul 9Pushed 8y ago12 watchersCompare

[ Source](https://github.com/hisune/tinymvc)[ Packagist](https://packagist.org/packages/hisune/tinymvc)[ RSS](/packages/hisune-tinymvc/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (1)

Hisune Tiny MVC Framework（此项目已经被弃用，推荐使用psr+composer自建框架）
========================================================

[](#hisune-tiny-mvc-framework此项目已经被弃用推荐使用psrcomposer自建框架)

- 简约为原则的高性能框架，包含：路由，ORM，cookie，session，view，validation，简单权限验证，cache等等。
- 自动生成增删改查代码(themeBuilder)
- 支持Mysql &amp;&amp; Mongodb
- 示例程序：
- 示例网站：

安装方法
====

[](#安装方法)

- 执行`composer create-project hisune/tinymvc-demo 2.2`
- composer帮助：()

> linux：
> `curl -sS https://getcomposer.org/installer | php`
> `mv composer.phar /usr/local/bin/composer`
> windows:
>

系统环境
====

[](#系统环境)

- Composer
- PHP 5.3+
- PDO extension

必须的参数配置
=======

[](#必须的参数配置)

- 可参考  中的 `app/Demo/bootstrap/autoload.php`

```
\Tiny\Config::$application = 'demo';
\Tiny\Config::$configDir = __DIR__ . '/../config/';
\Tiny\Config::$varDir = __DIR__ . '/../var/';
\Tiny\Config::$viewDir = __DIR__ . '/../view/';
\Tiny\Config::$controller = array('Controller', 'app/Controller');
register_shutdown_function(array('\Tiny\Exception', 'fatal'));
```

通用配置
====

[](#通用配置)

- config.php配置举例：

```
return array(
    'debug' => false, // 是否开启调试模式
    'flag' => 'xxoo', // session唯一标识
    'show_error' => false, // 是否显示错误
    'timezone' => 'PRC', // 时区
    'token' => false, // 自动加token
    'database' => array(
        'dns' => "mysql:host=127.0.0.1;port=3306;dbname=recharge;charset=UTF8", // 主从分离用逗号','隔开
        'username' => 'root',
        'password' => '',
        'prefix' => '',
        'separate' => false, // 主从分离
        'rand_read' => false, // 随机读取
        'log_queries' => false, // 是否记录所有请求
    ),
);
```

路由举例配置
======

[](#路由举例配置)

```
return array(
    // 路由配置
    'routes' => array(
        'admin' => 'admin', // 方式1，子模块模式
        'page/{id}' => function($id){ // 方式2，直接处理数据
            echo md5($id);
        },
        '{num}' => function ($num, &$controller, &$method, &$pathInfo) { // 方式3：指定c,m,p
            $controller = 'Index';
            $method = 'index';
            $pathInfo = array($num);
        },
        'param/{param?}' => function ($param, &$controller, &$method, &$pathInfo) { // 例：最后一个参数可不传递, 用'?'
            $controller = 'Index';
            $method = 'test';
            $pathInfo = array($param);
        },
    ),
    // 路由匹配后的正则配置
    'pattern' => array(
        'num' => '[0-9]+',
        'param' => '[0-9]*',
    ),
);
```

ORM介绍
=====

[](#orm介绍)

> 仿tp的orm，更简单，效率更优。注意使用时一定要绑定变量！
> 支持主从读写分离，支持主从随机读取；
> 对于直接执行原生sql语句，主库用execute，从库用query，原生sql也支持变量绑定
> 支持prefix
> 支持变量绑定的函数有：where，第一个参数为string，第二个参数为绑定变量数组
> 不支持变量绑定的函数有：field,group,having,order,table,join,limit，只支持一个string参数(limit除外)。limit会对传入的值强行intval，防止后端分页没有处理用户输入的安全隐患
> 对于链式操作，会在table和join中自动加入prefix，指定表的情况：\_\_TABLE\_NAME\_\_会转成：pre\_table\_name
> 对于query和execute不支持自动加入prefix，由于本身就是原生sql语句，直接写表名即可

- select使用方法(find)：

```
 $orders = new model\Orders;
 $orders
     ->alias('o') // 或者用 ->table('__ORDERS__ o')
     ->field('o.order, o.id')
     ->order('? desc', array('o.id'))
     ->where('o.id = ? or o.order = "?"',array("5' and 1=2 union select * from user where id=1/*")) //注入测试
     ->limit('1/*,1') // limit强制整型测试
     ->join('__TEST__ t on t.id = o.test_id', 'left')
     ->group('?', array('o.order'))
     ->having('count(*) > ?', array('1'))
     ->find() // find()无参数
```

- 其他CURD方法：

```
 findOne([int $id]) // R，指定id为where条件
 save([array $data], [boolean $replace]) // C
 update([array $data], [boolean $all]) // U，慎用all
 delete([int $id], [boolean $all]) // D，慎用all
 increment(string $column, [int $value]);
 query(string $sql, [array $param], [boolean $fetchAll])
 execute(string $sql, [array $param])
```

- 单列数据统计方法，多列或其他复杂情况用field：

```
 count([string $column])
 max([string $column])
 avg([string $column])
 min([string $column])
 sum([string $column])
 distinct([string $column])
```

- 其他说明：

```
field() //第一参数支持array，第一参数为array时，不支持别名，别名用string
where() //第一参数支持array，此时第二参数无效；第一参数为array时，不支持别名，别名请用string；只支持绑定条件变量。
limit() //支持string类似，limit('0, 10')，或双参数类似，limit(0, 10)
```

Theme Builder介绍
===============

[](#theme-builder介绍)

- 简单介绍

> 设计思想：不重复写模板和逻辑，通过简单配置实现某些通用功能。
> 设计思路：在控制器(controller)中指定附加action，theme builder读取辅助类(helper)中的配置进行处理。
> Tabs: bootstrap风格的tab，ajax显示content。
> Datatables:bootstrap风格的数据列表。可用作普通分页、排序、过滤列表或单纯table列表

- 需以下js插件支持：

> bootstrap
> bootbox
> daterangepicker
> multiselect

- 怎么使用？

> 安装完成后访问：/themeBuilder

- 示例(使用Hisune tinyMVC 开发的AdminLTE后台示例) themeBuilder 之 dataTable [![admin panel](https://raw.githubusercontent.com/hisune/images/master/tinymvc_admin_1.jpg)](https://raw.githubusercontent.com/hisune/images/master/tinymvc_admin_1.jpg)themeBuilder 之 mod [![admin panel](https://raw.githubusercontent.com/hisune/images/master/tinymvc_admin_2.jpg)](https://raw.githubusercontent.com/hisune/images/master/tinymvc_admin_2.jpg)

About
=====

[](#about)

**Created by Hisune [lyx](http://hisune.com)**

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~224 days

Recently: every ~288 days

Total

7

Last Release

2987d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a4ef0906f517b5dcc4658de9d066e7661a6267adcaff49c0cff77278d254e94?d=identicon)[hisune](/maintainers/hisune)

---

Top Contributors

[![hisune](https://avatars.githubusercontent.com/u/7941669?v=4)](https://github.com/hisune "hisune (64 commits)")

---

Tags

tiny frameworktiny MVChisune

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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