Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make doctrine/annotations dependency optional #2498

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR conflicting here is IMO OK just because we control the lib and said it's feature complete. Otherwise I'd be against having a conflict section as one could use the lib we're conflicting with, but not use it with ODM.

},
"suggest": {
"doctrine/annotations": "For annotation mapping support",
"ext-bcmath": "Decimal128 type support"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doctrine/annotations could be added to the suggest section

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having them in the suggestions can help if people read them and still need annotations. Older PHP versions still need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 added

"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