monomelodies/ornament
最新稳定版本:0.8.3
Composer 安装命令:
composer require monomelodies/ornament
包简介
PHP5 ORM toolkit
README 文档
README
PHP5 ORM toolkit
ORM is a fickle beast. Many libraries (e.g. Propel, Doctrine, Eloquent etc)
assume your database should correspond to your models. This is simply not the
case; models contain business logic and may, may not or may in part refer to
database tables, NoSQL databases, flat files, an external API or whatever. The
point is: the models shouldn't care, and there should be no "conventional"
mapping through their names. (A common example would be a model of pages in
multiple languages, where the data might be stored in a page table and a
page_i18n table for the language-specific data.)
Also, the use of extensive and/or complicated config files sucks. (XML? This is 2015, people!)
Installation
Composer (recommended)
Add "monomelodies/ornament" to your composer.json requirements:
$ composer require monomelodies/ornament
Manual installation
- Get the code;
- Clone the repository, e.g. from GitHub;
- Download the ZIP (e.g. from Github) and extract.
- Make your project recognize Ornament:
- Register
/path/to/ornament/srcfor the namespaceOrnament\\in your PSR-4 autoloader (recommended); - Alternatively, manually
includethe files you need.
- Register
Basic usage
Ornament models (or "entities" if you're used to Doctrine-speak) are really nothing more than vanilla PHP classes; there is no need to extend any base object of sorts (since you might want to do that in your own framework!).
Ornament is a toolkit, so it supplies a number of Traits one can use to
extend your models' behaviour beyond the ordinary.
The most basic implementation would look as follows:
<?php use Ornament\Model; use Ornament\Adapter\Pdo; class MyModel { use Model; // Public properties on a Model are considered "handleable" by Ornament: public $id; public $name; public $value; public function __construct() { $this->addAdapter(new Pdo($GLOBALS['database'])); } }
统计信息
- 总下载量: 207
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-24