Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 267 lines (184 sloc) 8.59 kB
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
1 Installing and configuring Doctrine PHPCR-ODM
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
2 =============================================
3
fbece45 Small tweaks to the PHPCR install doc
Lars Janssen authored
4 The Symfony2 CMF makes extensive use of the PHP Content Repository - Object Document Mapper
5 (PHPCR-ODM); in fact, it is required by the following CMF bundles: BlockBundle, ContentBundle,
6 MenuBundle, RoutingExtraBundle, SimpleCmsBundle and TreeBrowserBundle.
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
7
8 The goal of this tutorial is to install and configure Doctrine PHPCR-ODM, ready for you to get
9 started with the CMF.
10
11 For more details see the `official PHPCR-ODM documentation <http://www.doctrine-project.org/projects/phpcr-odm.html>`_.
12 Some additional information can be found on the `DoctrinePhpcrBundle github.com project <https://github.com/doctrine/DoctrinePHPCRBundle>`_,
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
13 which for the most part mimics the standard `DoctrineBundle <https://github.com/doctrine/DoctrineBundle>`_.
14
15 Finally for information about PHPCR see the `official PHPCR website <http://phpcr.github.com>`_.
16
17 .. index:: PHPCR, ODM
18
19 Preconditions
20 -------------
21 - php >= 5.3
22 - libxml version >= 2.7.0 (due to a bug in libxml http://bugs.php.net/bug.php?id=36501)
23 - phpunit >= 3.6 (if you want to run the tests)
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
24 - Symfony2 (version 2.1.x)
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
25
26 Installation
27 ------------
28
29 Choosing a content repository
30 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 The first thing to decide is what content repository to use. A content repository is essentially
32 a database that will be responsible for storing all the content you want to persist. It provides
f5c0bc7 @eriksencosta fixed typos
eriksencosta authored
33 an API that is optimized for the needs of a CMS (tree structures, references, versioning, full
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
34 text search etc.). While every content repository can have very different requirements and
35 performance characteristics, the API is the same for all of them.
36
37 Furthermore since the API defines an export/import format, you can always switch to a different
38 content repository implementation later on.
39
40 These are the available choices:
41
1028f2d Small fixes to a couple of tutorials.
Lars Janssen authored
42 * **Jackalope with Jackrabbit** (Jackrabbit requires Java, it can persist into the file system, a database etc.)
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
43 * **Jackalope with Doctrine DBAL** (requires an RDBMS like MySQL, PostgreSQL or SQLite)
44 * **Midgard** (requires the midgard2 PHP extension and an RDBMS like MySQL, PostgreSQL or SQLite)
45
46 The following documentation includes examples for all of the above options.
47
48 .. tip::
49
50 If you are just getting started with the CMF, it is best to choose a content repository based
51 on a storage engine that you are already familiar with. For example,
52 **Jackalope with Doctrine DBAL** will work with your existing RDBMS and does not require you
fbece45 Small tweaks to the PHPCR install doc
Lars Janssen authored
53 to install Java or the midgard2 PHP extension. Once you have a working application it should be
54 easy to switch to another option.
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
55
56
57 Download the bundles
58 ~~~~~~~~~~~~~~~~~~~~
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
59 Add the following to your ``composer.json`` file, depending on your chosen content repository.
60
61 | **Jackalope with Jackrabbit**
62 | **Jackalope with Doctrine DBAL**
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
63
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
64 .. code-block:: javascript
65
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
66 "require": {
67 ...
f4e170b @matteosister Update tutorials/installing-configuring-doctrine-phpcr-odm.rst
matteosister authored
68 "jackalope/jackalope-jackrabbit": "1.0.*",
69 "jackalope/jackalope-doctrine-dbal": "dev-master",
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
70 "doctrine/phpcr-bundle": "1.0.*",
f4e170b @matteosister Update tutorials/installing-configuring-doctrine-phpcr-odm.rst
matteosister authored
71 "doctrine/phpcr-odm": "1.0.*"
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
72 }
73
a9aa769 @dbu fixing lots of code block starts
dbu authored
74 .. Note::
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
75
8d2d548 @dbu make hint on orm version more understandable
dbu authored
76 If you are also using Doctrine ORM, make sure to use ``"doctrine/orm": "2.3.*"``,
77 otherwise composer can't resolve the dependencies as Doctrine PHPCR-ODM depends on
f5c0bc7 @eriksencosta fixed typos
eriksencosta authored
78 the newer 2.3 Doctrine Commons. (Symfony 2.1 standard edition uses "2.2.*".)
a9aa769 @dbu fixing lots of code block starts
dbu authored
79
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
80 **Midgard**
81
82 .. code-block:: javascript
83
84 "require": {
85 ...
86 "midgard/phpcr": "dev-master",
87 "doctrine/phpcr-bundle": "1.0.*",
88 "doctrine/phpcr-odm": "1.0.*"
89 }
90
91 To install the above dependencies, run:
a9aa769 @dbu fixing lots of code block starts
dbu authored
92
93 .. code-block:: bash
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
94
95 php composer.phar update
96
97 Register annotations
98 ~~~~~~~~~~~~~~~~~~~~
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
99 PHPCR-ODM uses annotations and these need to be registered in your ``app/autoload.php``
100 file. Add the following line, immediately after the last ``AnnotationRegistry::registerFile``
101 line:
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
102
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
103 .. code-block:: php
104
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
105 // app/autoload.php
106
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
107 // ...
108 AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
109 // ...
110
111 Initialize bundles
112 ~~~~~~~~~~~~~~~~~~
a9aa769 @dbu fixing lots of code block starts
dbu authored
113 Next, initialize the bundles in ``app/AppKernel.php`` by adding them to the
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
114 ``registerBundle`` method:
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
115
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
116 .. code-block:: php
117
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
118 // app/AppKernel.php
119
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
120 public function registerBundles()
121 {
122 $bundles = array(
123 // ...
124
125 // Doctrine PHPCR
126 new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
127
128 );
129 // ...
130 }
131
132
133 Configuration
134 -------------
135 Next step is to configure the bundles.
136
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
137 Doctrine PHPCR-ODM
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
138 ~~~~~~~~~~~~~~~~~~
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
139
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
140 Basic configuration for each content repository is shown below; add the appropriate lines to your
141 ``app/config/config.yml``. More information on configuring this bundle can be found
142 `on the Doctrine PHPCR project page <https://github.com/doctrine/DoctrinePHPCRBundle#readme>`_.
143
144
145
146 **Jackalope with Jackrabbit**
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
147
148 .. configuration-block::
149
150 .. code-block:: yaml
151
152 # app/config/config.yml
153 doctrine_phpcr:
154 session:
155 backend:
156 type: jackrabbit
157 url: http://localhost:8080/server/
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
158 workspace: default
159 username: admin
160 password: admin
161
162 **Jackalope with Doctrine DBAL**
163
164 .. configuration-block::
165
166 .. code-block:: yaml
167
168 # app/config/config.yml
169 doctrine_phpcr:
170 session:
171 backend:
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
172 type: doctrinedbal
173 connection: doctrine.dbal.default_connection
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
174 workspace: default
175 username: admin
176 password: admin
177
178 .. note::
179
180 Make sure you also configure the main ``doctrine:`` section for your chosen RDBMS.
181 See `Databases and Doctrine <http://symfony.com/doc/2.1/book/doctrine.html>`_.
182
183 **Midgard**
184
185 .. configuration-block::
186
187 .. code-block:: yaml
188
189 # app/config/config.yml
190 doctrine_phpcr:
191 session:
192 backend:
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
193 type: midgard2
194 db_type: MySQL
195 db_name: midgard2_test
196 db_host: "0.0.0.0"
197 db_port: 3306
198 db_username: ""
199 db_password: ""
200 db_init: true
201 blobdir: /tmp/cmf-blobs
202 workspace: default
203 username: admin
204 password: admin
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
205
206 Setting up the content repository
207 ---------------------------------
208
209 .. _tutorials-installing-phpcr-jackrabbit:
210
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
211 **Jackalope Jackrabbit**
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
212
213 .. index:: Jackrabbit
214
215 These are the steps necessary to install Apache Jackrabbit:
216
a9aa769 @dbu fixing lots of code block starts
dbu authored
217 - Make sure you have Java Virtual Machine installed on your box. If not, you can
218 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
219 - 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
220 - 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
221
089c765 @lsmith77 some more cleanups and typo fixes
lsmith77 authored
222 .. code-block:: bash
223
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
224 java -jar jackrabbit-standalone-*.jar
225
226 Going to http://localhost:8080/ should now display a Apache Jackrabbit page.
227
228 More information about `running a Jackrabbit server <https://github.com/jackalope/jackalope/wiki/Running-a-jackrabbit-server>`_
229 can be found on the Jackalope wiki.
230
231 .. _tutorials-installing-phpcr-doctrinedbal:
232
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
233 **Jackalope Doctrine DBAL**
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
234
235 .. index:: Doctrine, DBAL, RDBMS
236
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
237 Run the following commands to create the database and set up a default schema:
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
238
239 .. code-block:: bash
240
241 app/console doctrine:database:create
242 app/console doctrine:phpcr:init:dbal
243
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
244 For more information on how to configure Doctrine DBAL with Symfony2, see the
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
245 `Doctrine chapter in the Symfony2 documentation <http://symfony.com/doc/current/book/doctrine.html>`_
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
246 and the explanations in the :ref:`PHPCR reference chapter <reference-phpcr-doctrinedbal>`.
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
247
248 .. _tutorials-installing-phpcr-midgard:
249
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
250 **Midgard**
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
251
252 .. index:: Midgard, RDBMS
253
254 Midgard is a C extension that implements the PHPCR API on top of a standard RDBMS.
255
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
256 See the `official Midgard PHPCR documentation <http://midgard-project.org/phpcr/>`_.
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
257
258 Registering system node types
259 -----------------------------
8f43821 @lsmith77 lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
260 PHPCR-ODM uses a `custom node type <https://github.com/doctrine/phpcr-odm/wiki/Custom-node-type-phpcr%3Amanaged>`_
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tw…
Lars Janssen authored
261 to track meta information without interfering with your content. There is a command that makes it
262 trivial to register this type and the PHPCR namespace:
1fd2ef6 @dbu adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
263
264 .. code-block:: bash
265
266 php app/console doctrine:phpcr:register-system-node-types
Something went wrong with that request. Please try again.