Skip to content

Commit c9b7f6b

Browse files
authored
Merge pull request #2498 from franmomu/option_annotations
Make `doctrine/annotations` dependency optional
2 parents 495b583 + 540139d commit c9b7f6b

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

UPGRADE-2.7.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
## doctrine/persistence
99

1010
* MongoDB ODM 2.7 requires `doctrine/persistence` 3.2 or newer.
11+
12+
## `doctrine/annotations` is optional
13+
14+
ODM no longer requires `doctrine/annotations` to be installed. If you're using
15+
annotations for mapping, you will need to install `doctrine/annotations`.

composer.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"require": {
2424
"php": "^8.1",
2525
"ext-mongodb": "^1.11",
26-
"doctrine/annotations": "^1.12 || ^2.0",
2726
"doctrine/cache": "^1.11 || ^2.0",
2827
"doctrine/collections": "^1.5 || ^2.0",
2928
"doctrine/event-manager": "^1.0 || ^2.0",
@@ -39,6 +38,7 @@
3938
},
4039
"require-dev": {
4140
"ext-bcmath": "*",
41+
"doctrine/annotations": "^1.12 || ^2.0",
4242
"doctrine/coding-standard": "^12.0",
4343
"jmikola/geojson": "^1.0",
4444
"phpbench/phpbench": "^1.0.0",
@@ -49,7 +49,11 @@
4949
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
5050
"vimeo/psalm": "^5.9.0"
5151
},
52+
"conflict": {
53+
"doctrine/annotations": "<1.12 || >=3.0"
54+
},
5255
"suggest": {
56+
"doctrine/annotations": "For annotation mapping support",
5357
"ext-bcmath": "Decimal128 type support"
5458
},
5559
"autoload": {

docs/en/reference/annotations-reference.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Annotations Reference
22
=====================
33

4+
.. note::
5+
6+
To be able to use annotations, you will have to install an extra
7+
package called ``doctrine/annotations``.
8+
49
In this chapter a reference of every Doctrine 2 ODM Annotation is
510
given with short explanations on their context and usage.
611

docs/en/reference/basic-mapping.rst

+14-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ document mapping metadata:
3232
Introduction to Docblock Annotations
3333
------------------------------------
3434

35+
.. note::
36+
37+
To be able to use annotations, you will have to install an extra
38+
package called ``doctrine/annotations``.
39+
3540
You've probably used docblock annotations in some form already,
3641
most likely to provide documentation metadata for a tool like
3742
``PHPDocumentor`` (@author, @link, ...). Docblock annotations are a
@@ -44,12 +49,15 @@ chances of clashes with other docblock annotations, the Doctrine
4449
docblock annotations feature an alternative syntax that is heavily
4550
inspired by the Annotation syntax introduced in Java 5.
4651

47-
The implementation of these enhanced docblock annotations is
48-
located in the ``Doctrine\Common\Annotations`` namespace and
49-
therefore part of the Common package. Doctrine docblock annotations
50-
support namespaces and nested annotations among other things. The
51-
Doctrine MongoDB ODM defines its own set of docblock annotations
52-
for supplying object document mapping metadata.
52+
The implementation of these enhanced docblock annotations is located in
53+
the ``doctrine/annotations`` package, but in the
54+
``Doctrine\Common\Annotations`` namespace for backwards compatibility
55+
reasons. Note that ``doctrine/annotations`` is not required by Doctrine
56+
MongoDB ODM, and you will need to require that package if you want to use
57+
annotations. Doctrine MongoDB ODM docblock annotations support namespaces and
58+
nested annotations among other things. The Doctrine MongoDB ODM defines its
59+
own set of docblock annotations for supplying object-relational mapping
60+
metadata.
5361

5462
.. note::
5563

docs/en/reference/metadata-drivers.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ a document.
3737
3838
$em->getConfiguration()->setMetadataCacheImpl(new ApcCache());
3939
40-
If you want to use one of the included core metadata drivers you
41-
just need to configure it. All the drivers are in the
40+
If you want to use one of the included core metadata drivers you need to
41+
configure it. If you pick the annotation driver, you will additionally
42+
need to install ``doctrine/annotations``. All the drivers are in the
4243
``Doctrine\ODM\MongoDB\Mapping\Driver`` namespace:
4344

4445
.. code-block:: php

0 commit comments

Comments
 (0)