Skip to content

PHP Standardization #156

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

Merged
merged 167 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
a1df675
Add PR template
norareidy Aug 6, 2024
ef92914
Scaffolding
norareidy Aug 6, 2024
42838af
DOCSP-41953: Create a deployment (#93)
norareidy Aug 7, 2024
aab488d
DOCSP-41954: Create a connection string (#99)
norareidy Aug 8, 2024
2419c76
DOCSP-42388: Next steps (#101)
norareidy Aug 8, 2024
e994533
DOCSP-41975: Retrieve data (#102)
norareidy Aug 19, 2024
1104051
DOCSP-41952: Download and Install (#92)
norareidy Aug 21, 2024
f4d7b49
DOCSP-41976: Projection guide (#104)
norareidy Aug 21, 2024
3887028
DOCSP-41955: Connect to MongoDB (#100)
norareidy Aug 27, 2024
cbead21
DOCSP-41974: Specify a query (#103)
norareidy Aug 27, 2024
474fc1f
DOCSP-41977: Specify documents to return (#105)
norareidy Aug 27, 2024
ad5b511
DOCSP-41957 - Mongo Client (#106)
mongoKart Aug 27, 2024
bdd0fca
DOCSP-41960 - TLS (#114)
mongoKart Aug 28, 2024
09c7be4
DOCSP-41978: Count documents (#108)
norareidy Aug 29, 2024
7e0f9be
DOCSP-41979: Distinct values (#109)
norareidy Sep 3, 2024
cd4c81f
DOCSP-41981: Change streams (#113)
norareidy Sep 5, 2024
169702e
DOCSP-41993 Compatibility Table
lindseymoore Sep 5, 2024
c956ae9
test webhook
lindseymoore Sep 5, 2024
c20a191
toc and sharedincludes
lindseymoore Sep 5, 2024
ea7b0e0
lang table
lindseymoore Sep 5, 2024
9dd5843
edits
lindseymoore Sep 5, 2024
f59251d
headings
lindseymoore Sep 5, 2024
3b0efec
retry on shared include
lindseymoore Sep 5, 2024
4253547
shared includes
lindseymoore Sep 5, 2024
7a3b381
callout
lindseymoore Sep 5, 2024
c826670
help links
lindseymoore Sep 5, 2024
429ea3b
DOCSP-41958 - Connection Targets (#107)
mongoKart Sep 6, 2024
5e0723d
tech review
lindseymoore Sep 6, 2024
017275c
DOCSP-41968: Update documents (#118)
norareidy Sep 9, 2024
e5973db
DOCSP-41967: Insert documents (#116)
norareidy Sep 9, 2024
a4b3796
DOCSP-41980: Cursor guide (#110)
norareidy Sep 9, 2024
f7d2584
DOCSP-41988: Aggregation (#115)
norareidy Sep 9, 2024
3cae058
DOCSP-41983: indexes landing pg
rustagir Sep 5, 2024
d65dae9
wip
rustagir Sep 5, 2024
2477f39
wip
rustagir Sep 5, 2024
4abb6de
MM PR fixes 1
rustagir Sep 6, 2024
e227a7f
JM tech review 1
rustagir Sep 10, 2024
b18b221
JM tech review 1
rustagir Sep 10, 2024
a8de178
wip
rustagir Sep 10, 2024
69668bd
wip
rustagir Sep 10, 2024
280b0f7
DOCSP-41969: Replace documents (#125)
norareidy Sep 10, 2024
cbc3879
JM tech review 2
rustagir Sep 10, 2024
3362eb1
Add files via upload
branberry Sep 10, 2024
b9825a1
DOCSP-41970: Delete documents (#128)
norareidy Sep 10, 2024
55a44c1
Merge pull request #127 from rustagir/DOCSP-41983-indexes-landing
rustagir Sep 10, 2024
7a1a929
DOCSP-41984: single field index
rustagir Sep 10, 2024
4b16ca3
wip
rustagir Sep 10, 2024
334e565
JS PR fixes 1
rustagir Sep 11, 2024
afd284a
wip
rustagir Sep 11, 2024
1f70e6d
Merge pull request #134 from rustagir/DOCSP-41984-single-fld-idx
rustagir Sep 12, 2024
4fd1451
DOCSP-41986: multikey indexes
rustagir Sep 12, 2024
3148b8f
links
rustagir Sep 12, 2024
5437492
bullet pts
rustagir Sep 12, 2024
3435135
JS suggestion
rustagir Sep 13, 2024
6e59711
fix whitespace per JM comment
rustagir Sep 13, 2024
60f5c9c
uncomment
rustagir Sep 13, 2024
a040fa8
Merge pull request #140 from rustagir/DOCSP-41986-multikey-indexes
rustagir Sep 13, 2024
d762275
DOCSP-41985: compound idx
rustagir Sep 13, 2024
a497539
small fix
rustagir Sep 16, 2024
4e1994b
DOCSP-41966: Write operations landing (#135)
norareidy Sep 16, 2024
54c05bf
DOCSP-42026: In use encryption (#142)
norareidy Sep 16, 2024
df79843
DOCSP-41972: GridFS guide (#133)
norareidy Sep 16, 2024
668f3dc
DOCSP-41971: Bulk write (#130)
norareidy Sep 17, 2024
a772b6a
Merge pull request #141 from rustagir/DOCSP-41985-compound-idx
rustagir Sep 17, 2024
4adaec3
DOCSP-41987: atlas search idx
rustagir Sep 17, 2024
6df74fd
resolve todos
rustagir Sep 17, 2024
90abbca
toc
rustagir Sep 17, 2024
bde5e59
DOCSP-41963: Databases and collections (#136)
norareidy Sep 17, 2024
61fba29
JS fix
rustagir Sep 17, 2024
1524f11
internal review
lindseymoore Sep 17, 2024
dd28d66
Merge pull request #143 from rustagir/DOCSP-41987-atlas-search-dx
rustagir Sep 18, 2024
5dcbd15
DOCSP-41982: cluster monitoring
rustagir Sep 17, 2024
564dfe9
small fixes
rustagir Sep 17, 2024
fce8972
MW PR fixes 1
rustagir Sep 18, 2024
ba51cd6
test netlify
lindseymoore Sep 18, 2024
8b9a970
merge
lindseymoore Sep 18, 2024
13d1651
spacing
lindseymoore Sep 18, 2024
f8c0b5e
try using out of repo ref and add back legend
lindseymoore Sep 18, 2024
321c3dd
ou of repo ref
lindseymoore Sep 18, 2024
26d4a5e
legend glitch
lindseymoore Sep 18, 2024
9dfc72a
JM tech review 1
rustagir Sep 19, 2024
8cf4fc1
single quotes
rustagir Sep 19, 2024
fc1506c
links
rustagir Sep 19, 2024
25d4f88
vale
rustagir Sep 19, 2024
ae53fbb
remove older driver version past 1.15
lindseymoore Sep 19, 2024
9ad7615
Merge pull request #126 from lindseymoore/DOCSP-41993
lindseymoore Sep 19, 2024
265476f
DOCSP-41991 What's New
lindseymoore Sep 19, 2024
13ff962
add rest of versions
lindseymoore Sep 20, 2024
99c571d
fix links
lindseymoore Sep 20, 2024
de61ae1
fix links
lindseymoore Sep 20, 2024
e3351c5
JM tech review 2
rustagir Sep 23, 2024
5812fdf
DOCSP-41964: Time series collections (#138)
norareidy Sep 23, 2024
4a39d20
JM final fixes
rustagir Sep 23, 2024
e2cc75b
Merge pull request #144 from rustagir/DOCSP-41982-cluster-monitoring
rustagir Sep 23, 2024
122f58f
review comments
lindseymoore Sep 23, 2024
c4b9611
typo
lindseymoore Sep 23, 2024
a5f2990
DOCSP-41973 Read Landing Page
lindseymoore Sep 23, 2024
83aa662
review comments
lindseymoore Sep 23, 2024
f3de45a
vale errors
lindseymoore Sep 24, 2024
d6803c4
small thing
lindseymoore Sep 24, 2024
6f5cdc7
Merge pull request #145 from lindseymoore/DOCSP-41991
lindseymoore Sep 24, 2024
f11a302
full page with ex
lindseymoore Sep 24, 2024
fc6dfda
add page
lindseymoore Sep 24, 2024
1680c76
meta
lindseymoore Sep 24, 2024
16de291
DOCSP-41965: Read and write settings (#146)
norareidy Sep 25, 2024
855563c
DOCSP-41950: Landing page (#150)
norareidy Sep 25, 2024
e236d7a
edit sample app intro
lindseymoore Sep 25, 2024
ac0e57d
change links in count sections
lindseymoore Sep 25, 2024
23738fd
update sample app intro
lindseymoore Sep 25, 2024
3bb2cb7
DOCSP-41990: Authentication mechanisms (#139)
norareidy Sep 25, 2024
f0e562c
DOCSP-41989: Security landing page (#149)
norareidy Sep 25, 2024
f31eb3e
DOCSP-41962 - Stable API (#117)
mongoKart Sep 25, 2024
585da96
DOCSP-41992 Upgrade versions
lindseymoore Sep 25, 2024
15e475f
toc
lindseymoore Sep 25, 2024
9670327
edits
lindseymoore Sep 25, 2024
8482514
how to upgrade sections
lindseymoore Sep 25, 2024
dfe83b7
style
lindseymoore Sep 25, 2024
6e3538d
edit
lindseymoore Sep 25, 2024
6610b56
edit
lindseymoore Sep 25, 2024
8988322
review comments
lindseymoore Sep 26, 2024
ce8408f
ref
lindseymoore Sep 26, 2024
13de83c
Revise descriptions for server opening/closed events
jmikola Sep 26, 2024
993076b
DOCSP-43204: Connection landing page (#147)
norareidy Sep 26, 2024
61dc28d
DOCSP-43819: php 1.20 release
rustagir Sep 26, 2024
014899b
fix
rustagir Sep 26, 2024
9ca3ff3
Merge pull request #155 from rustagir/DOCSP-43819-php-1.20
rustagir Sep 26, 2024
f03fe5b
Merge pull request #153 from mongodb/jmikola-patch-1
rustagir Sep 26, 2024
992b952
DOCSP-41956: run a command
rustagir Sep 6, 2024
954c3d2
wip
rustagir Sep 6, 2024
832a457
formatting fix
rustagir Sep 6, 2024
b6495a0
JS PR fixes 1
rustagir Sep 6, 2024
2dcacc0
link fix
rustagir Sep 6, 2024
ea882c2
style fixes
rustagir Sep 6, 2024
13e1c13
JT tech review 1
rustagir Sep 9, 2024
47d3717
wip
rustagir Sep 9, 2024
b5da5ab
JM tech review
rustagir Sep 25, 2024
3e0710d
tree
rustagir Sep 25, 2024
b77281b
api links
rustagir Sep 25, 2024
b08b7bf
links
rustagir Sep 25, 2024
8918fbf
JM tech review 2
rustagir Sep 26, 2024
5053786
small fixes
rustagir Sep 26, 2024
9a7aa08
add ext upgrade command
lindseymoore Sep 26, 2024
fcc5736
DOCSP-41995: transaction
rustagir Sep 11, 2024
ada33fc
wip
rustagir Sep 11, 2024
8218890
update code
rustagir Sep 11, 2024
0492a7f
NR PR fixes 1
rustagir Sep 11, 2024
b85aed7
wip
rustagir Sep 11, 2024
73ee986
add emphasis
rustagir Sep 11, 2024
f107bc9
add with_txn() method to api links
rustagir Sep 11, 2024
3ede497
cxn string env
rustagir Sep 26, 2024
807fc78
edit
lindseymoore Sep 26, 2024
2c12b6b
JM tech review 1
rustagir Sep 26, 2024
d5a8d53
remove dupe sc
rustagir Sep 26, 2024
36b360c
tech review
lindseymoore Sep 26, 2024
63c1926
Merge branch 'php-standardization' into DOCSP-41973
lindseymoore Sep 26, 2024
c14727a
Merge pull request #148 from lindseymoore/DOCSP-41973
lindseymoore Sep 26, 2024
baf5e13
wrap fix
rustagir Sep 27, 2024
17074d6
Merge pull request #137 from rustagir/DOCSP-41995-txn
rustagir Sep 27, 2024
f4834bf
Merge pull request #129 from rustagir/DOCSP-41956-run-command
rustagir Sep 27, 2024
f03e46c
edit copy
lindseymoore Sep 27, 2024
953a10e
Merge branch 'php-standardization' into DOCSP-41992
lindseymoore Sep 27, 2024
91b7c60
Merge pull request #152 from lindseymoore/DOCSP-41992
lindseymoore Sep 27, 2024
cf2b492
DOCSP-41959 - Connection Options (#112)
mongoKart Sep 27, 2024
1274cc6
DOCSP-43396: Cleanup (#151)
norareidy Sep 27, 2024
5f4582e
Merge remote-tracking branch 'upstream/master' into php-standardization
norareidy Sep 27, 2024
61a36a7
build fix
norareidy Sep 27, 2024
7ce2aa8
php directives
norareidy Sep 27, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ build/*
build
*~
*giza.log
source/*
backups/*
vendor/
composer.lock
Expand Down
1 change: 0 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ name = "snooty-cache-plugin"
# set in your site’s Branches settings in the UI will inherit
# these settings.
[build]

publish = "snooty/public"
command = ". ./build.sh"
27 changes: 26 additions & 1 deletion snooty.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name = "php-library"
title = "PHP Library Manual"

intersphinx = ["https://www.mongodb.com/docs/manual/objects.inv"]
intersphinx = [
"https://www.mongodb.com/docs/manual/objects.inv",
"https://www.mongodb.com/docs/drivers/objects.inv",
"https://www.mongodb.com/docs/atlas/objects.inv",
]

toc_landing_pages = [
"/reference/class/MongoDBClient",
Expand All @@ -17,10 +21,31 @@ toc_landing_pages = [
"/reference/class/MongoDBModelCollectionInfo",
"/reference/class/MongoDBModelDatabaseInfo",
"/reference/class/MongoDBModelIndexInfo",
"/get-started",
"/connect",
"/read",
"/databases-collections",
"/write",
"/indexes",
"/security",
"/data-formats",
"/upgrade",
]

sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"

[substitutions]
php-library = "MongoDB PHP Library"

[constants]
php-library = "MongoDB PHP Library"
extension-short = "PHP extension"
mdb-server = "MongoDB Server"
stable-api = "Stable API"
library-short = "PHP library"
driver-short = "{+library-short+}"
api = "https://www.mongodb.com/docs/php-library/current/reference"
php-manual = "https://www.php.net/manual/en"
string-data-type = "``string``"
bool-data-type = "``bool``"
int-data-type = "``int``"
205 changes: 205 additions & 0 deletions source/aggregation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
.. _php-aggregation:

====================================
Transform Your Data with Aggregation
====================================

.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, transform, computed, pipeline
:description: Learn how to use the PHP library to perform aggregation operations.

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

.. TODO:
.. toctree::
:titlesonly:
:maxdepth: 1

/aggregation/aggregation-tutorials

Overview
--------

In this guide, you can learn how to use the {+php-library+} to perform
**aggregation operations**.

Aggregation operations process data in your MongoDB collections and
return computed results. The MongoDB Aggregation framework, which is
part of the Query API, is modeled on the concept of data processing
pipelines. Documents enter a pipeline that contains one or more stages,
and this pipeline transforms the documents into an aggregated result.

An aggregation operation is similar to a car factory. A car factory has
an assembly line, which contains assembly stations with specialized
tools to do specific jobs, like drills and welders. Raw parts enter the
factory, and then the assembly line transforms and assembles them into a
finished product.

The **aggregation pipeline** is the assembly line, **aggregation stages** are the
assembly stations, and **operator expressions** are the
specialized tools.

Aggregation Versus Find Operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can use find operations to perform the following actions:

- Select which documents to return
- Select which fields to return
- Sort the results

You can use aggregation operations to perform the following actions:

- Run find operations
- Rename fields
- Calculate fields
- Summarize data
- Group values

Limitations
~~~~~~~~~~~

Consider the following limitations when performing aggregation operations:

- Returned documents cannot violate the
:manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
of 16 megabytes.
- Pipeline stages have a memory limit of 100 megabytes by default. You can exceed this
limit by creating an options array that sets the ``allowDiskUse`` option to ``true``
and passing the array to the ``MongoDB\Collection::aggregate()`` method.

.. important:: $graphLookup Exception

The :manual:`$graphLookup
</reference/operator/aggregation/graphLookup/>` stage has a strict
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.

.. _php-aggregation-example:

Aggregation Example
-------------------

.. note::

The examples in this guide use the ``restaurants`` collection in the ``sample_restaurants``
database from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to create a
free MongoDB Atlas cluster and load the sample datasets, see the :atlas:`Get Started with Atlas
</getting-started>` guide.

To perform an aggregation, pass an array containing the pipeline stages to
the ``MongoDB\Collection::aggregate()`` method.

The following code example produces a count of the number of bakeries in each borough
of New York. To do so, it uses an aggregation pipeline that contains the following stages:

- :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents
in which the ``cuisine`` field contains the value ``'Bakery'``

- :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching
documents by the ``borough`` field, accumulating a count of documents for each distinct
value

.. io-code-block::
:copyable:

.. input:: /includes/aggregation.php
:start-after: start-match-group
:end-before: end-match-group
:language: php
:dedent:

.. output::
:visible: false

{"_id":"Brooklyn","count":173}
{"_id":"Queens","count":204}
{"_id":"Bronx","count":71}
{"_id":"Staten Island","count":20}
{"_id":"Missing","count":2}
{"_id":"Manhattan","count":221}

Explain an Aggregation
~~~~~~~~~~~~~~~~~~~~~~

To view information about how MongoDB executes your operation, you can
instruct the MongoDB query planner to **explain** it. When MongoDB explains
an operation, it returns **execution plans** and performance statistics.
An execution plan is a potential way in which MongoDB can complete an operation.
When you instruct MongoDB to explain an operation, it returns both the
plan MongoDB executed and any rejected execution plans.

To explain an aggregation operation, construct a ``MongoDB\Operation\Aggregate`` object
and pass the database, collection, and pipeline stages as parameters. Then, pass the
``MongoDB\Operation\Aggregate`` object to the ``MongoDB\Collection::explain()`` method.

The following example instructs MongoDB to explain the aggregation operation
from the preceding :ref:`php-aggregation-example`:

.. io-code-block::
:copyable:

.. input:: /includes/aggregation.php
:start-after: start-explain
:end-before: end-explain
:language: php
:dedent:

.. output::
:visible: false

{"explainVersion":"2","queryPlanner":{"namespace":"sample_restaurants.restaurants",
"indexFilterSet":false,"parsedQuery":{"cuisine":{"$eq":"Bakery"}},"queryHash":"865F14C3",
"planCacheKey":"D56D6F10","optimizedPipeline":true,"maxIndexedOrSolutionsReached":false,
"maxIndexedAndSolutionsReached":false,"maxScansToExplodeReached":false,"winningPlan":{
... }

Additional Information
----------------------

To view a tutorial that uses the {+php-library+} to create complex aggregation
pipelines, see `Complex Aggregation Pipelines with Vanilla PHP and MongoDB

Check failure on line 168 in source/aggregation.txt

View workflow job for this annotation

GitHub Actions / vale

[vale] source/aggregation.txt#L168

[MongoDB.GlobalAudienceMetaphorical] Use 'standard' instead of the metaphor 'Vanilla'.
Raw output
{"message": "[MongoDB.GlobalAudienceMetaphorical] Use 'standard' instead of the metaphor 'Vanilla'.", "location": {"path": "source/aggregation.txt", "range": {"start": {"line": 168, "column": 52}}}, "severity": "ERROR"}
<https://www.mongodb.com/developer/products/mongodb/aggregations-php-mongodb/>`__
in the MongoDB Developer Center.

MongoDB Server Manual
~~~~~~~~~~~~~~~~~~~~~

To learn more about the topics discussed in this guide, see the following
pages in the {+mdb-server+} manual:

- To view a full list of expression operators, see :manual:`Aggregation
Operators </reference/operator/aggregation/>`.

- To learn about assembling an aggregation pipeline and to view examples, see
:manual:`Aggregation Pipeline </core/aggregation-pipeline/>`.

- To learn more about creating pipeline stages, see :manual:`Aggregation
Stages </reference/operator/aggregation-pipeline/>`.

- To learn more about explaining MongoDB operations, see
:manual:`Explain Output </reference/explain-results/>` and
:manual:`Query Plans </core/query-plans/>`.

.. TODO:
Aggregation Tutorials
~~~~~~~~~~~~~~~~~~~~~

.. To view step-by-step explanations of common aggregation tasks, see
.. :ref:`php-aggregation-tutorials-landing`.

API Documentation
~~~~~~~~~~~~~~~~~

To learn more about the methods discussed in this guide, see the
following API documentation:

- :phpmethod:`MongoDB\Collection::aggregate()`
- :phpmethod:`MongoDB\Collection::explain()`
62 changes: 62 additions & 0 deletions source/compatibility.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _php-compatibility:

=============
Compatibility
=============

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

.. facet::
:name: genre
:values: reference

.. meta::
:keywords: backwards compatibility, versions, upgrade

MongoDB Compatibility
---------------------

The following compatibility table specifies the recommended version or versions
of the {+php-library+} and extension that you can use with a specific version of MongoDB.

The first column lists the version of the library and extension.

.. sharedinclude:: dbx/lifecycle-schedule-callout.rst

.. sharedinclude:: dbx/compatibility-table-legend.rst

.. include:: /includes/mongodb-compatibility-table-php.rst

For more information on how to read the compatibility tables, see our guide on
:ref:`MongoDB Compatibility Tables <about-driver-compatibility>`.

Language Compatibility
----------------------

The following compatibility table specifies the recommended version or versions
of the {+php-library+} and extension that you can use with a specific version of PHP.

The first column lists the version of the library and extension.

.. include:: /includes/language-compatibility-table-php.rst

For more information on how to read the compatibility tables, see our guide on
:ref:`MongoDB Compatibility Tables <about-driver-compatibility>`.

How to Get Help
---------------

If you have questions about compatibility, visit the following resources for further guidance:

- Ask questions on our :community-forum:`MongoDB Community Forums <>`.
- Visit our :technical-support:`Support Channels </>`.
- File an issue or feature request in our issue tracker, JIRA, under one of the
following projects:

- `PHPC - Extension <https://jira.mongodb.org/projects/PHPC/summary>`_

- `PHPLIB - Library <https://jira.mongodb.org/projects/PHPLIB/summary>`_
Loading
Loading