Skip to content
Newer
Older
100644 212 lines (147 sloc) 6.71 KB
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored Oct 27, 2012
1 Installing and configuring Doctrine PHPCR-ODM
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
2 =============================================
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored Oct 27, 2012
3 The goal of this tutorial is to install and configure Doctrine PHPCR-ODM.
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
4
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored Oct 27, 2012
5 For more details see the `official PHPCR-ODM documentation <http://www.doctrine-project.org/projects/phpcr-odm.html>`_
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
6 Some additional information can be found on the
7 `DoctrinePhpcrBundle github.com project <https://github.com/doctrine/DoctrinePHPCRBundle>`_
8 which for the most part mimics the standard `DoctrineBundle <https://github.com/doctrine/DoctrineBundle>`_.
9
10 Finally for information about PHPCR see the `official PHPCR website <http://phpcr.github.com>`_.
11
12 .. index:: PHPCR, ODM
13
14 Preconditions
15 -------------
16 - php >= 5.3
17 - libxml version >= 2.7.0 (due to a bug in libxml http://bugs.php.net/bug.php?id=36501)
18 - phpunit >= 3.6 (if you want to run the tests)
19 - Symfony2.1 (currently master)
20
21 Installation
22 ------------
23
24 Choosing a content repository
25 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
27 The first thing to decide is what content repository to use. A content repository is essentially
28 a database that will be responsible for storing all the content you want to persist. It provides
29 and API that is optimized for the needs of a CMS (tree structures, references, versioning, full
30 text search etc.). While every content repository can have very different requirements and
31 performance characteristics, the API is the same for all of them.
32
33 Furthermore since the API defines an export/import format, you can always switch to a different
34 content repository implementation later on.
35
36 These are the available choices:
37
38 * Jackalope with Jackrabbit (Jackrabbit requires Java, it can persist into the file system, a database etc.)
39 * Jackalope with Doctrine DBAL (requires an RDBMS like MySQL, PostgreSQL or SQLite)
40 * Midgard (requires an RDBMS like MySQL, PostgreSQL or SQLite)
41
42 Depending on your choice you can omit certain steps in the following documentation.
43
44 Download the bundles
45 ~~~~~~~~~~~~~~~~~~~~
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
46 Add the following to your ``composer.json`` file
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
47
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 16, 2012
48 .. code-block:: javascript
49
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
50 "require": {
51 ...
52 "jackalope/jackalope-jackrabbit": "1.0.*"
53 "jackalope/jackalope-doctrine-dbal": "dev-master"
54 "midgard/phpcr": "dev-master"
55 "doctrine/phpcr-bundle": "1.0.*",
56 "doctrine/phpcr-odm": "1.0.*",
57 }
58
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
59 .. Note::
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
60
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
61 Remember to check if you are using "doctrine/orm": "2.2.*" (Symfony 2.1
62 default) and switch to "2.3.*" before updating.
63
64 And then run
65
66 .. code-block:: bash
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
67
68 php composer.phar update
69
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
70
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
71 Register annotations
72 ~~~~~~~~~~~~~~~~~~~~
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
73 Add file to annotation registry in ``app/autoload.php`` for the ODM annotations
74 right after the last ``AnnotationRegistry::registerFile`` line
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
75
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 15, 2012
76 .. code-block:: php
77
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
78 // ...
79 AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
80 // ...
81
82 Initialize bundles
83 ~~~~~~~~~~~~~~~~~~
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
84 Next, initialize the bundles in ``app/AppKernel.php`` by adding them to the
85 ``registerBundle`` method
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
86
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 15, 2012
87 .. code-block:: php
88
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
89 public function registerBundles()
90 {
91 $bundles = array(
92 // ...
93
94 // Doctrine PHPCR
95 new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
96
97 );
98 // ...
99 }
100
101
102 Configuration
103 -------------
104 Next step is to configure the bundles.
105
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored Oct 27, 2012
106 Doctrine PHPCR-ODM
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
107 ~~~~~~~~~~~~~~~~~~
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 15, 2012
108
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
109 Basic configuration, add to your application configuration
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 15, 2012
110
111 .. configuration-block::
112
113 .. code-block:: yaml
114
115 # app/config/config.yml
116 doctrine_phpcr:
117 session:
118 backend:
119 # Jackalope Jackrabbit
120 type: jackrabbit
121 url: http://localhost:8080/server/
122 # Jackalope Doctrine DBAL (make sure to also configure the DoctrineBundle accordingly)
123 type: doctrinedbal
124 connection: doctrine.dbal.default_connection
125 # Midgard
126 type: midgard2
127 db_type: MySQL
128 db_name: midgard2_test
129 db_host: "0.0.0.0"
130 db_port: 3306
131 db_username: ""
132 db_password: ""
133 db_init: true
134 blobdir: /tmp/cmf-blobs
135 workspace: default
136 username: admin
137 password: admin
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
138
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
139 More information on configuring this bundle can be found
140 `here <https://github.com/doctrine/DoctrinePHPCRBundle#readme>`_.
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
141
142 Setting up the content repository
143 ---------------------------------
144
145 .. _tutorials-installing-phpcr-jackrabbit:
146
147 Jackalope Jackrabbit
148 ~~~~~~~~~~~~~~~~~~~~
149
150
151 .. index:: Jackrabbit
152
153 These are the steps necessary to install Apache Jackrabbit:
154
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
155 - Make sure you have Java Virtual Machine installed on your box. If not, you can
156 grab one from here: http://www.java.com/en/download/manual.jsp
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
157 - Download the latest version from the `Jackrabbit Downloads page <http://jackrabbit.apache.org/downloads.html>`_
a9aa769 @dbu fixing lots of code block starts
dbu authored Oct 16, 2012
158 - Run the server. Go to the folder where you downloaded the .jar file and launch it
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
159
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored Oct 15, 2012
160 .. code-block:: bash
161
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
162 java -jar jackrabbit-standalone-*.jar
163
164 Going to http://localhost:8080/ should now display a Apache Jackrabbit page.
165
166 More information about `running a Jackrabbit server <https://github.com/jackalope/jackalope/wiki/Running-a-jackrabbit-server>`_
167 can be found on the Jackalope wiki.
168
169 As we are using Jackalope as our PHPCR implementation we could also chose other storage backends
170 like relational databases but for this tutorial we're going to use Jackrabbit.
171
172
173 .. _tutorials-installing-phpcr-doctrinedbal:
174
175 Jackalope Doctrine DBAL
176 ~~~~~~~~~~~~~~~~~~~~~~~
177
178 .. index:: Doctrine, DBAL, RDBMS
179
180 In order to setup the database, run the following commands to create the
181 database and setup a default schema
182
183 .. code-block:: bash
184
185 app/console doctrine:database:create
186 app/console doctrine:phpcr:init:dbal
187
188 For more information of how to configure Doctrine DBAL with Symfony2 see the
189 `Doctrine chapter in the Symfony2 documentation <http://symfony.com/doc/current/book/doctrine.html>`_
190 and the explanations in the :ref:`PHPCR reference chapter <reference-phpcr-doctrinedbal>`).
191
192 .. _tutorials-installing-phpcr-midgard:
193
194 Midgard
195 ~~~~~~~
196
197 .. index:: Midgard, RDBMS
198
199 Midgard is a C extension that implements the PHPCR API on top of a standard RDBMS.
200
201 See `official Midgard PHPCR documentation <http://midgard-project.org/phpcr/>`_
202
203 Registering system node types
204 -----------------------------
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored Oct 27, 2012
205 PHPCR-ODM uses a `custom node type <https://github.com/doctrine/phpcr-odm/wiki/Custom-node-type-phpcr%3Amanaged>`_
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored Oct 15, 2012
206 to track meta information without interfering with your content. There is a command that makes it trivial to
207 register this type and the PHPCR namespace
208
209 .. code-block:: bash
210
211 php app/console doctrine:phpcr:register-system-node-types
Something went wrong with that request. Please try again.