RedBeanPHP

RedBeanPHP是易于使用的PHP的ORM。她是一个零配置ORM库,可自动地构建您的数据库模式。(RedBeanPHP is an easy to use ORM for PHP. It's a Zero Config ORM lib that 'automagically' builds your database schema.)

Github stars Tracking Chart

RedBeanPHP是一个简单的、易于使用的即时对象映射器,特别适合于RAD,原型设计和设定具体期限的人员。 RedBeanPHP自动创建表、列、约束和索引,所以您不必一直在数据库客户端(phpMyAdmin)和编辑器之间切换(这并不意味着您永远不必使用phpMyAdmin或SQL,接着读下去...)。 此外,您不必编写配置文件,因为RedBeanPHP只是从命名约定推断数据库模式。 因为RedBeanPHP节省了大量的时间,您可以花更多的时间来开发应用程序的其余部分。

无配置

大多数ORM使用配置文件(XML,INI或YAML)或某种注释系统来定义映射。 这些系统强制您先将记录映射到对象。 RedBeanPHP是不同的。 而不是使用配置,它使用约定; 一套很小的规则。 RedBeanPHP使用这些约定来推断关系并自动化映射。 RedBeanPHP还可以通过自动构建初始表和列来帮助您遵循这些约定,这也节省了大量时间。 这意味着没有配置,更少的样板代码和更多的时间专注于业务逻辑,测试和文档,从而提高开发生产力和代码质量。

对象和记录之间的桥梁
SQL是关系数据库的强大查询语言。 大多数ORM都像墙一样,从你身上隐藏SQL。 RedBeanPHP另一方面试图整合这两种技术,从而更像一座桥梁。 例如,RedBeanPHP允许您在ORM方法中嵌入SQL代码片段,以调整数据库中相关bean的检索。 RedBeanPHP寻求在面向对象编程和关系数据库查询之间取得平衡。
代码质量

RedBeanPHP经过精心设计,简洁易用。 核心代码库每天使用本地服务器和Travis CI环境进行约20.000个单元测试(100%测试覆盖)进行测试。 代码库包含大量的内联文档,完全面向对象,通过宣传基于PDO的准备语句和参数绑定来提高安全性。

RedBeanPHP支持所有众所周知的开源关系数据库。 提供官方支持的有:MySQL,MariaDB,PostgreSQL,SQLite和CUBRID。 其他数据库的支持可能由第三方提供。

RedBeanPHP特点:

  • 自动创建表和列
  • 没有配置,即发即弃(fire and forget)
  • 没有复杂的包装工具,没有自动装载机,只有一个文件
要求:
  • 简短版本第一...最低要求
  • GNU /Linux,BSD,Windows
  • PHP 5.3.0或更高版本(建议使用PHP 5.3.4+)
  • PDO加您的数据库的驱动程序
  • 多字节字符串支持

Main metrics

Overview
Name With Ownergabordemooij/redbean
Primary LanguagePHP
Program languagePHP (Language Count: 2)
Platform
License:
所有者活动
Created At2009-05-29 07:39:09
Pushed At2025-05-29 22:27:49
Last Commit At2025-05-01 19:41:56
Release Count38
Last Release Namev5.7.5 (Posted on 2025-05-30 00:27:38)
First Release Namev3.2 (Posted on 2012-05-07 23:29:12)
用户参与
Stargazers Count2.3k
Watchers Count88
Fork Count278
Commits Count3k
Has Issues Enabled
Issues Count735
Issue Open Count2
Pull Requests Count148
Pull Requests Open Count0
Pull Requests Close Count69
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

RedBeanPHP 5

Build Status

RedBeanPHP is an easy to use ORM tool for PHP.

  • Automatically creates tables and columns as you go
  • No configuration, just fire and forget
  • No complicated package tools, no autoloaders, just ONE file

Download RedBeanPHP from the website:

https://redbeanphp.com/download

Extract the archive and put it in your PHP project, voila!

Optional: sha256sum and check signature.

Just open your composer.json file and add the package name (e.g. "gabordemooij/redbean": "dev-master") in your require list.

{
    "require": {
        "gabordemooij/redbean": "dev-master"
    }
}

NOTE:
You will find many examples on the RedBean website make use of RedBean's R class. Because of namespaced autoloading in Composer, this class will be available as \RedbeanPHP\R instead of R. If you desire to use the much shorter R alias, you can add a use statement at the beginning of your code:

use \RedBeanPHP\R as R;

NOTE:
It is important to note that when using RedBeanPHP with Composer, there are some extra precautions needed when working with Models. Due to the namespace requirements of Composer, when creating Models we need to use the SimpleModel to extend, not RedBean_SimpleModel. Furthermore, we need to specify the namespace of the SimpleModel, so a full example of using a Model with RedBean with Composer is as follows:

use \RedBeanPHP\R;

class Model_User extends \RedBeanPHP\SimpleModel
{
    ...
}

Notice that we also need to add the use \RedBeanPHP\R statement so that we can use the R:: shortcut within the Model.

Quick Example

How we store a book object with RedBeanPHP:

$book = R::dispense("book");
$book->author = "Santa Claus";
$book->title = "Secrets of Christmas";
$id = R::store( $book );

Yep, it's that simple.

More information

For more information about RedBeanPHP please consult
the RedBeanPHP website:

https://www.redbeanphp.com/