Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 275 lines (191 sloc) 8.844 kb
8f43821 Lukas Kahwe Smith lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
1 Installing and configuring Doctrine PHPCR-ODM
1fd2ef6 David Buchmann 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, tweak...
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 David Buchmann 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, tweak...
Lars Janssen authored
25 - Symfony2 (version 2.1.x)
1fd2ef6 David Buchmann 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 Eriksen Costa fixed typos
eriksencosta authored
34 an API that is optimized for the needs of a CMS (tree structures, references, versioning, full
1fd2ef6 David Buchmann 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
38 Furthermore since the API defines an export/import format, you can always switch to a different
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, tweak...
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 David Buchmann 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, tweak...
Lars Janssen authored
60 Add the following to your ``composer.json`` file, depending on your chosen content repository.
61
62 | **Jackalope with Jackrabbit**
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
63
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
64 .. code-block:: javascript
65
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
66 "require": {
67 ...
f4e170b Matteo Giachino Update tutorials/installing-configuring-doctrine-phpcr-odm.rst
matteosister authored
68 "jackalope/jackalope-jackrabbit": "1.0.*",
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
69 "doctrine/phpcr-bundle": "1.0.*",
f4e170b Matteo Giachino Update tutorials/installing-configuring-doctrine-phpcr-odm.rst
matteosister authored
70 "doctrine/phpcr-odm": "1.0.*"
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
71 }
72
1f9e667 Changes following pull request comments.
Lars Janssen authored
73 | **Jackalope with Doctrine DBAL**
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
74
1f9e667 Changes following pull request comments.
Lars Janssen authored
75 .. code-block:: javascript
76
77 "require": {
78 ...
79 "jackalope/jackalope-doctrine-dbal": "dev-master",
80 "doctrine/phpcr-bundle": "1.0.*",
81 "doctrine/phpcr-odm": "1.0.*"
82 }
a9aa769 David Buchmann fixing lots of code block starts
dbu authored
83
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
84 **Midgard**
85
86 .. code-block:: javascript
87
88 "require": {
89 ...
90 "midgard/phpcr": "dev-master",
91 "doctrine/phpcr-bundle": "1.0.*",
92 "doctrine/phpcr-odm": "1.0.*"
93 }
94
1f9e667 Changes following pull request comments.
Lars Janssen authored
95 .. Note::
96
97 For all of the above, if you are also using Doctrine ORM, make sure to use
98 ``"doctrine/orm": "2.3.*"``, otherwise composer can't resolve the dependencies as Doctrine
99 PHPCR-ODM depends on the newer 2.3 Doctrine Commons. (Symfony 2.1 standard edition uses "2.2.*".)
100
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
101 To install the above dependencies, run:
a9aa769 David Buchmann fixing lots of code block starts
dbu authored
102
103 .. code-block:: bash
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
104
105 php composer.phar update
106
107 Register annotations
108 ~~~~~~~~~~~~~~~~~~~~
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
109 PHPCR-ODM uses annotations and these need to be registered in your ``app/autoload.php``
110 file. Add the following line, immediately after the last ``AnnotationRegistry::registerFile``
111 line:
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
112
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
113 .. code-block:: php
114
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
115 // app/autoload.php
116
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
117 // ...
118 AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
119 // ...
120
121 Initialize bundles
122 ~~~~~~~~~~~~~~~~~~
a9aa769 David Buchmann fixing lots of code block starts
dbu authored
123 Next, initialize the bundles in ``app/AppKernel.php`` by adding them to the
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
124 ``registerBundle`` method:
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
125
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
126 .. code-block:: php
127
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
128 // app/AppKernel.php
129
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
130 public function registerBundles()
131 {
132 $bundles = array(
133 // ...
134
135 // Doctrine PHPCR
136 new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
137
138 );
139 // ...
140 }
141
142
143 Configuration
144 -------------
145 Next step is to configure the bundles.
146
8f43821 Lukas Kahwe Smith lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
147 Doctrine PHPCR-ODM
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
148 ~~~~~~~~~~~~~~~~~~
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
149
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
150 Basic configuration for each content repository is shown below; add the appropriate lines to your
151 ``app/config/config.yml``. More information on configuring this bundle can be found
152 `on the Doctrine PHPCR project page <https://github.com/doctrine/DoctrinePHPCRBundle#readme>`_.
153
154 **Jackalope with Jackrabbit**
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
155
156 .. configuration-block::
157
158 .. code-block:: yaml
159
160 # app/config/config.yml
161 doctrine_phpcr:
162 session:
163 backend:
164 type: jackrabbit
165 url: http://localhost:8080/server/
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
166 workspace: default
167 username: admin
168 password: admin
169
170 **Jackalope with Doctrine DBAL**
171
172 .. configuration-block::
173
174 .. code-block:: yaml
175
176 # app/config/config.yml
177 doctrine_phpcr:
178 session:
179 backend:
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
180 type: doctrinedbal
181 connection: doctrine.dbal.default_connection
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
182 workspace: default
183 username: admin
184 password: admin
185
186 .. note::
187
188 Make sure you also configure the main ``doctrine:`` section for your chosen RDBMS.
189 See `Databases and Doctrine <http://symfony.com/doc/2.1/book/doctrine.html>`_.
190
191 **Midgard**
192
193 .. configuration-block::
194
195 .. code-block:: yaml
196
197 # app/config/config.yml
198 doctrine_phpcr:
199 session:
200 backend:
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
201 type: midgard2
202 db_type: MySQL
203 db_name: midgard2_test
204 db_host: "0.0.0.0"
205 db_port: 3306
206 db_username: ""
207 db_password: ""
208 db_init: true
209 blobdir: /tmp/cmf-blobs
210 workspace: default
211 username: admin
212 password: admin
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
213
214 Setting up the content repository
215 ---------------------------------
216
217 .. _tutorials-installing-phpcr-jackrabbit:
218
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
219 **Jackalope Jackrabbit**
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
220
221 .. index:: Jackrabbit
222
223 These are the steps necessary to install Apache Jackrabbit:
224
a9aa769 David Buchmann fixing lots of code block starts
dbu authored
225 - Make sure you have Java Virtual Machine installed on your box. If not, you can
226 grab one from here: http://www.java.com/en/download/manual.jsp
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
227 - Download the latest version from the `Jackrabbit Downloads page <http://jackrabbit.apache.org/downloads.html>`_
a9aa769 David Buchmann fixing lots of code block starts
dbu authored
228 - Run the server. Go to the folder where you downloaded the .jar file and launch it
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
229
089c765 Lukas Kahwe Smith some more cleanups and typo fixes
lsmith77 authored
230 .. code-block:: bash
231
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
232 java -jar jackrabbit-standalone-*.jar
233
234 Going to http://localhost:8080/ should now display a Apache Jackrabbit page.
235
236 More information about `running a Jackrabbit server <https://github.com/jackalope/jackalope/wiki/Running-a-jackrabbit-server>`_
237 can be found on the Jackalope wiki.
238
239 .. _tutorials-installing-phpcr-doctrinedbal:
240
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
241 **Jackalope Doctrine DBAL**
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
242
243 .. index:: Doctrine, DBAL, RDBMS
244
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
245 Run the following commands to create the database and set up a default schema:
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
246
247 .. code-block:: bash
248
249 app/console doctrine:database:create
250 app/console doctrine:phpcr:init:dbal
251
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
252 For more information on how to configure Doctrine DBAL with Symfony2, see the
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
253 `Doctrine chapter in the Symfony2 documentation <http://symfony.com/doc/current/book/doctrine.html>`_
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
254 and the explanations in the :ref:`PHPCR reference chapter <reference-phpcr-doctrinedbal>`.
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
255
256 .. _tutorials-installing-phpcr-midgard:
257
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
258 **Midgard**
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
259
260 .. index:: Midgard, RDBMS
261
262 Midgard is a C extension that implements the PHPCR API on top of a standard RDBMS.
263
e2449f5 More Doctrine PHPCR-ODM content-specific examples, clarifications, tweak...
Lars Janssen authored
264 See the `official Midgard PHPCR documentation <http://midgard-project.org/phpcr/>`_.
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
265
266 Registering system node types
267 -----------------------------
8f43821 Lukas Kahwe Smith lots of details, added SonataDoctrinePhpcrAdminBundle
lsmith77 authored
268 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, tweak...
Lars Janssen authored
269 to track meta information without interfering with your content. There is a command that makes it
270 trivial to register this type and the PHPCR namespace:
1fd2ef6 David Buchmann adding doc on phpcr-odm bundle and lots of cleanup
dbu authored
271
272 .. code-block:: bash
273
274 php app/console doctrine:phpcr:register-system-node-types
Something went wrong with that request. Please try again.