Skip to content

HTTPS clone URL

Subversion checkout URL

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