4zend/zpropel

使用 Propel ORM 集成 Zend Framework 2

dev-master 2014-04-15 02:35 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:56:14 UTC


README

Zend Framework 2 的 Propel ORM 模块

通过 Composer 安装

"require": { "4zend/zpropel": "dev-master" }

开始使用

查看 demo 目录以获取示例项目,然后创建项目文件在: data/zpropel/proxy

  • 将 "Zpropel" 添加到 config/application.config.php 文件中的 modules 键
  • 在 data/zpropel/proxy 中编写您的项目文件(schema.xml, runtime-conf.xml, build.properties)
  • 进入您的 ZF2 应用程序的 public/ 目录并运行: php index.php propel-gen

用法

一旦您的项目被 "构建",您就可以使用 "Zpropel" 命名空间从任何地方访问类。

例如:$author = new \Zpropel\Author();

事件

Zpropel 包含一个专门为触发 Propel "钩子" 而设计的 Propel 行为,作为 ZF2 事件管理器的事件。

例如:观察一个共享事件

$eventManager->getSharedManager()->attach('zpropel', 'author_preSave', function($e){
    $author = $e->getTarget();
    // do something
}, 100);`