PHPackages                             hackyoung/leno - 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. hackyoung/leno

ActiveLibrary[Framework](/categories/framework)

hackyoung/leno
==============

A simple clean framework

v0.3.1.x-dev(9y ago)2166MITPHP

Since Jun 11Pushed 9y ago2 watchersCompare

[ Source](https://github.com/hackyoung/leno)[ Packagist](https://packagist.org/packages/hackyoung/leno)[ RSS](/packages/hackyoung-leno/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (6)Used By (0)

\#LenoPHP

```
|---------|
| LenoPHP |
|---|-----|
    |
    |---Database
    |    |---------------|
    |---ORM              |
    |            |初     |
    |---Worker---|始    |业
    |            |化    |务
    |                   |逻
    |            |路    |辑
    |---Router---|由     |
    |                    |
    |---Controller-------|
    |
    |---View----|试图

```

\###ORM

```
namespace Test;

use \Test\Entity\BookEntity as Book;
use \Test\Entity\UserEntity as Author;

$author = new Author;
$author->setName('hackyoung')
    ->setAge(24);

$book = new Book;
$book->setName('Javascript从入门到放弃')
    ->setPublished(new \Datetime);

$author->setBook($book);

$book = new Book;
$book->setName('教你如何放弃敲代码')
    ->setPublished(new \Datetime);

$author->addBook($book);

$author->save(); // 两本书一起被保存了，yeah ^_^
```

假设刚刚保存的用户ID是'id'

```
namespace Test;

use \Test\Entity\BookEntity as Book;
use \Test\Entity\UserEntity as Author;

$author = Author::find('id');

// 查出刚刚添加的书
$author->getBook(function($selector) {
    return $selector->order('published', 'ASC');
});

// 只查Javascript从入门到放弃
// 啥？第一个参数false是什么意思？哦，它禁用上次查询book的缓存
// 默认是true，false的意思是给我再去数据库里找一次，条件变了

$author->getBook(false, function($selector) {
    return $selector->byNameLike('javascript');
});
```

\###Database

selector

```
namespace Test;

use \Test\Entity\UserEntity as User;

$user = User::selector()->byNameLike('young')
    ->byAgeGt(24)
    ->findOne();

$books = Book::selector()->byAuthor($user)->find();

// complex
$users = User::selector()
    ->quoteBegin()
     ->byNameLike('young')
     ->or()
     ->byNameLike('hack')
    ->quoteEnd()
    ->byAgeGt(24);

// with join

$user_selector = User::selector()->field([
    'name' => 'author_name'
])->byAge(24); // byAge === byAgeEq

$book_selector = Book::selector();

$books_array = $book_selector->join(
    $user_selector->onId($book_selector->getFieldExpr('author_id'))
)->execute()->fetchAll();
```

table

```
namespace Test;

$table = new Table('hello_world');

$table->setPrimaryKey('hello_id')
    ->field('hello_id', ['type' => 'uuid'])
    ->field('content', ['type' => 'varchar(64)'])
    ->field('user_id', ['type' => 'uuid'])
    ->field('created', ['type' => 'datetime', 'is_nullable' => true])
    ->setUniqueKeys(['content_unique' => ['content']])
    ->setForeignKeys(['user' => ['foreign_table' => 'user', 'relation' => [
        'user_id' => 'user_id'
    ]]);

// 不仅仅save，还会比对和数据库中的变化，同步字段及约束
$table->save();

// 也许你仅仅需要执行一条 vendor/bin/leno build db --entity-dir /path/to/entity --namespace /namespace/of/entity
// 程序会帮你同步所有的表结构及约束进数据库
```

\###View

```

        {$user.hello}

            {$item}

```

控件

```

    .atl-item {
    }

    console.log('just one');

    {$title}

        {$overview}

        删除
        编辑

```

\###Controller

```
namespace Controller;

use \Leno\Controller as LenoController;

class Article extends LenoController
{
    // RESTFUL POST的默认处理方法
    // POST /article
    public function add()
    {
        // 获取前端输入
        $username = $this->input('username', ['type' => 'email']);
        $user_data = $this->inputs([
            'username' => ['type' => 'email'],
            'password' => ['type' => 'string', 'extra' => [
                'max_length' => 64
            ]],
            'nickname' => ['type' => 'string', 'extra' => [
                'max_length' => 32
            ]]
        ]);

        try {
            $this->getService('xxx')->setUserName($username)
                ->execute();
        } catch (\Exception $ex) {
            // handle exception
        }

        return $this->output('操作成功');
    }

    // RESTFUL PUT的默认处理方法
    // PUT /article
    public function modify()
    {
    }

    // RESTFUL DELETE的默认处理方法
    // DELETE /article
    public function remove()
    {
    }

    // RESTFUL INDEX的默认处理方法
    // GET /article
    public function index($id = null)
    {
        if ($id) {
            // return Article of id;
        }
        // return Article list
    }
}
```

\#介绍 LenoPHP是一个简单干净的PHP框架，有如下特性:

- 支持Mysql,和Pgsql,基于PDO的ORM,且方便拓展
- 支持继承,嵌套,条件输出,标签的模板系统
- 设计清晰的路由,可自定义规则,支持RESTFUL路由风格,可自定义action绑定
- 命令行自动化工具,自动安装应用
- "强制service",合理化业务逻辑类的粒度
- 简单的配置系统

\#安装 LenoPHP通过composer进行管理,如果你不知道什么是composer,不要担心,10分钟就能掌握它

```
composer require hackyoung/leno
```

之后你会看到一个vendor目录,且已经支持psr0,psr4. 然后就是自动化初始化环境

```
cd path/to/project_dir && vendor/bin/leno hello_world --root .
```

\#文档 编辑进行中...

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Every ~11 days

Total

4

Last Release

3637d ago

### Community

Maintainers

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

---

Top Contributors

[![hackyoung](https://avatars.githubusercontent.com/u/3030341?v=4)](https://github.com/hackyoung "hackyoung (291 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.7k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M497](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k37](/packages/neuron-core-neuron-ai)

PHPackages © 2026

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