richardjh / rjhredbean
RedbeanPHP ORM module for ZF2
Requires
- php: >=5.2.0
- gabordemooij/redbean: dev-master
This package is not auto-updated.
Last update: 2018-04-29 09:35:29 UTC
README
RedbeanPHP ORM module for Zend Framework 2
Installation
Install using composer, for example
composer require richardjh/rjhredbean:dev-master
and configure as a ZF2 module in config/application.config.php
'modules' => array(
'Application',
'richardjh\rjhredbean',
),
Configuration
Copy vendor/richardjh/rjhredbean/config/autoload/local.php.dist to config/autoload/rjhredbean.local.php and enter the database settings. You can find more information about this at http://www.redbeanphp.com/manual/compatible
Usage
To get a configured instance of Redbean to use in your controller, do it like this:
public function indexAction()
{
$rb = $this->getServiceLocator()->get('RjhRedbean');
$t = $rb->dispense("foo1");
$t->when = time();
$rb->store($t);
}
Alternatively to get a configured instance of Redbean into a Service or Model simple implement the RedbeanAwareInterface provided and and the RedbeanAwareInitializer will inject the Redbean instance for you.
Using newer versions of Redbean (>v3.5.1)
Versions of RedbeanPHP newer that v3.5.1 aren't published on packagist and therefore RjhRedbean cannot load them directly. There is a simple solution by editing the composer.json file in your own ZF2 project. Please read http://richardjh.org/blog/use-latest-redbean-rjhredbean.php for details on how to do this.