Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (58 sloc) 2.644 kb
b7bce75 @mariano Adding README
authored
1 li3_doctrine2 offers integration between [the most RAD PHP framework] [lithium]
2 and possibly the best PHP 5.3 ORM out there: [Doctrine2] [doctrine2]
3
4 # License #
5
6 li3_doctrine2 is released under the [BSD License] [license].
7
8 # Installation #
9
10 It is recommended that you install li3_doctrine2 as a GIT submodule, in order
11 to keep up with the latest upgrades. To do so, switch to the core directory
12 holding your lithium application, and do:
13
14 ```bash
15 $ git submodule add https://mariano@github.com/mariano/li3_doctrine2.git app/libraries/li3_doctrine2
16 $ cd app/libraries/li3_doctrine2 && git submodule update --init
17 $ cd _source/doctrine2 && git submodule update --init
18 ```
19
20 # Using DoctrineExtensions #
21
22 If there is one tool I would recommend you checkout for your Doctrine models,
e811e60 @mariano Fixing link reference in README
authored
23 that would be [DoctrineExtensions] [DoctrineExtensions]. It provides with a set
b7bce75 @mariano Adding README
authored
24 of behavioral extensions to the Doctrine core that will simplify your
25 development.
26
27 To use DoctrineExtensions, you should first add it as GIT submodule. To do so,
28 switch to the core directory holding your lithium application, and do:
29
30 ```bash
31 $ git submodule add https://github.com/l3pp4rd/DoctrineExtensions.git app/libraries/_source/DoctrineExtensions
32 ```
33
34 Next you would use your connection configuration (in `app/config/connections.php`)
35 to configure Doctrine with your desired behaviors. For example, if you wish
36 to use Timestampable and Sluggable, you would first add the library in
37 `app/config/libraries.php`:
38
39 ```php
40 Libraries::add('Gedmo', array(
41 'path' => Libraries::get('app', 'path') . '/libraries/_source/DoctrineExtensions/lib/Gedmo'
42 ));
43 ```
44
45 And then you would the `createEntityManager` connection option in the
46 connection defied in `app/config/connections.php` to implement the callable that
47 enables the behaviors:
48
49 ```php
50 Connections::add('default', array(
51 'type' => 'Doctrine',
52 'driver' => 'pdo_mysql',
53 'host' => 'localhost',
54 'user' => 'root',
55 'password' => 'password',
56 'dbname' => 'my_db',
57 'createEntityManager' => function(array $params) {
58 $params['eventManager']->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
59 $params['eventManager']->addEventSubscriber(new \Gedmo\Sluggable\SluggableListener());
60
61 return \Doctrine\ORM\EntityManager::create(
62 $params['connection'],
63 $params['configuration'],
64 $params['eventManager']
65 );
66 }
67 ));
68 ```
69
70 [lithium]: http://lithify.me
71 [doctrine2]: http://www.doctrine-project.org
72 [license]: http://www.opensource.org/licenses/bsd-license.php
73 [DoctrineExtensions]: https://github.com/l3pp4rd/DoctrineExtensions
Something went wrong with that request. Please try again.