Skip to content

Commit

Permalink
Merge pull request #2498 from franmomu/option_annotations
Browse files Browse the repository at this point in the history
Make `doctrine/annotations` dependency optional
  • Loading branch information
malarzm authored Jan 2, 2024
2 parents 495b583 + 540139d commit c9b7f6b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
5 changes: 5 additions & 0 deletions UPGRADE-2.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
## doctrine/persistence

* MongoDB ODM 2.7 requires `doctrine/persistence` 3.2 or newer.

## `doctrine/annotations` is optional

ODM no longer requires `doctrine/annotations` to be installed. If you're using
annotations for mapping, you will need to install `doctrine/annotations`.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"require": {
"php": "^8.1",
"ext-mongodb": "^1.11",
"doctrine/annotations": "^1.12 || ^2.0",
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/collections": "^1.5 || ^2.0",
"doctrine/event-manager": "^1.0 || ^2.0",
Expand All @@ -39,6 +38,7 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/annotations": "^1.12 || ^2.0",
"doctrine/coding-standard": "^12.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0",
Expand All @@ -49,7 +49,11 @@
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"vimeo/psalm": "^5.9.0"
},
"conflict": {
"doctrine/annotations": "<1.12 || >=3.0"
},
"suggest": {
"doctrine/annotations": "For annotation mapping support",
"ext-bcmath": "Decimal128 type support"
},
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions docs/en/reference/annotations-reference.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Annotations Reference
=====================

.. note::

To be able to use annotations, you will have to install an extra
package called ``doctrine/annotations``.

In this chapter a reference of every Doctrine 2 ODM Annotation is
given with short explanations on their context and usage.

Expand Down
20 changes: 14 additions & 6 deletions docs/en/reference/basic-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ document mapping metadata:
Introduction to Docblock Annotations
------------------------------------

.. note::

To be able to use annotations, you will have to install an extra
package called ``doctrine/annotations``.

You've probably used docblock annotations in some form already,
most likely to provide documentation metadata for a tool like
``PHPDocumentor`` (@author, @link, ...). Docblock annotations are a
Expand All @@ -44,12 +49,15 @@ chances of clashes with other docblock annotations, the Doctrine
docblock annotations feature an alternative syntax that is heavily
inspired by the Annotation syntax introduced in Java 5.

The implementation of these enhanced docblock annotations is
located in the ``Doctrine\Common\Annotations`` namespace and
therefore part of the Common package. Doctrine docblock annotations
support namespaces and nested annotations among other things. The
Doctrine MongoDB ODM defines its own set of docblock annotations
for supplying object document mapping metadata.
The implementation of these enhanced docblock annotations is located in
the ``doctrine/annotations`` package, but in the
``Doctrine\Common\Annotations`` namespace for backwards compatibility
reasons. Note that ``doctrine/annotations`` is not required by Doctrine
MongoDB ODM, and you will need to require that package if you want to use
annotations. Doctrine MongoDB ODM docblock annotations support namespaces and
nested annotations among other things. The Doctrine MongoDB ODM defines its
own set of docblock annotations for supplying object-relational mapping
metadata.

.. note::

Expand Down
5 changes: 3 additions & 2 deletions docs/en/reference/metadata-drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ a document.
$em->getConfiguration()->setMetadataCacheImpl(new ApcCache());
If you want to use one of the included core metadata drivers you
just need to configure it. All the drivers are in the
If you want to use one of the included core metadata drivers you need to
configure it. If you pick the annotation driver, you will additionally
need to install ``doctrine/annotations``. All the drivers are in the
``Doctrine\ODM\MongoDB\Mapping\Driver`` namespace:

.. code-block:: php
Expand Down

0 comments on commit c9b7f6b

Please sign in to comment.