Skip to content

Commit d08acbc

Browse files
norareidymongoKartrustagirlindseymoorealcaeus
authored
PHP Standardization (#156)
* Add PR template * Scaffolding * DOCSP-41953: Create a deployment (#93) * DOCSP-41953: Create a deployment * toc * add troubleshoot file * DOCSP-41954: Create a connection string (#99) * DOCSP-41954: Create a connection string * edits * spacing * DOCSP-42388: Next steps (#101) * DOCSP-41975: Retrieve data (#102) * DOCSP-41975: Retrieve data * fixes * quotes * code fix * JS feedback * JT feedback * code format * fix * JT feedback 2 * edit * DOCSP-41952: Download and Install (#92) * DOCSP-41952: Download and Install * edits * toc, fixes * AS feedback * AS feedback 2 * typo * JT feedback * DOCSP-41976: Projection guide (#104) * DOCSP-41976: Projection guide * edits * fixes * code edits, output * JS feedback * JT feedback * DOCSP-41955: Connect to MongoDB (#100) * DOCSP-41955: Connect to MongoDB * edits * edit * RR feedback * typo * code edit * DOCSP-41974: Specify a query (#103) * DOCSP-41974: Specify a query * edits * output * fix * snooty.toml * RR feedback * code edits * DOCSP-41977: Specify documents to return (#105) * DOCSP-41977: Specify documents to return * edits * code output * toc * MM feedback, code edits * edit * JT feedback * edit * test * MM feedback 2 * DOCSP-41957 - Mongo Client (#106) Co-authored-by: Rea Rustagi <[email protected]> * DOCSP-41960 - TLS (#114) * DOCSP-41978: Count documents (#108) * DOCSP-41978: Count documents * edits * code ex format * link * RR feedback * DOCSP-41979: Distinct values (#109) Adds a Distinct Values guide. * DOCSP-41981: Change streams (#113) Adds a Change Streams guide. * DOCSP-41993 Compatibility Table * test webhook * toc and sharedincludes * lang table * edits * headings * retry on shared include * shared includes * callout * help links * DOCSP-41958 - Connection Targets (#107) Co-authored-by: Nora Reidy <[email protected]> Co-authored-by: Andreas Braun <[email protected]> * tech review * DOCSP-41968: Update documents (#118) * DOCSP-41968: Update documents * snooty fix * edits * DOCSP-41967: Insert documents (#116) * DOCSP-41967: Insert documents * build * snooty * edit * JS feedback * JT feedback * JT feedback 2 * DOCSP-41980: Cursor guide (#110) * DOCSP-41980: Cursor guide * edits * code edits * output * vale fix * MM feedback * edit * fix code ex * edit * JT feedback * DOCSP-41988: Aggregation (#115) * DOCSP-41988: Aggregation * toc * edits * code edit * JS feedback * dev center * JM feedback * explain api link * JM feedback 2 * DOCSP-41983: indexes landing pg * wip * wip * MM PR fixes 1 * JM tech review 1 * JM tech review 1 * wip * wip * DOCSP-41969: Replace documents (#125) * DOCSP-41969: Replace documents * edits * wording * SA * JT feedback * JM tech review 2 * Add files via upload * DOCSP-41970: Delete documents (#128) Adds a guide that shows how to delete documents. * DOCSP-41984: single field index * wip * JS PR fixes 1 * wip * DOCSP-41986: multikey indexes * links * bullet pts * JS suggestion * fix whitespace per JM comment * uncomment * DOCSP-41985: compound idx * small fix * DOCSP-41966: Write operations landing (#135) * DOCSP-41966: Write operations landing * edits * RR feedback * JT feedback * JT feedback 2 * gridfs examples * DOCSP-42026: In use encryption (#142) * DOCSP-42026: In use encryption * edit * DOCSP-41972: GridFS guide (#133) * DOCSP-41972: GridFS guide * fixes * code edits * fix * RR feedback * phpmethod * fix * JM most feedback * alternate upload/download methods * file revisions * code fix * tojson * edits * JM feedback 2 * edits * JM last feedback * DOCSP-41971: Bulk write (#130) * DOCSP-41971: Bulk write * edits * JS feedback * api links * DOCSP-41987: atlas search idx * resolve todos * toc * DOCSP-41963: Databases and collections (#136) * DOCSP-41963: Databases and collections * edits * phpmethod * code fix * MW feedback * fix * MW feedback 2 * JM feedback * JM feedback 2 * JS fix * internal review * DOCSP-41982: cluster monitoring * small fixes * MW PR fixes 1 * test netlify * spacing * try using out of repo ref and add back legend * ou of repo ref * legend glitch * JM tech review 1 * single quotes * links * vale * remove older driver version past 1.15 * DOCSP-41991 What's New * add rest of versions * fix links * fix links * JM tech review 2 * DOCSP-41964: Time series collections (#138) * DOCSP-41964: Time series collections * toc * edits * keywords * SA feedback * JT feedback * JM final fixes * review comments * typo * DOCSP-41973 Read Landing Page * review comments * vale errors * small thing * full page with ex * add page * meta * DOCSP-41965: Read and write settings (#146) * DOCSP-41965: Read and write settings * more info * edits * edits * headers * fix link * fix * RR feedback * api docs * fix * fix * DOCSP-41950: Landing page (#150) * DOCSP-41950: Landing page * fix build errors * fixes, data formats * toc * fix * data formats folder * RR feedback * fix * remove file * edit sample app intro * change links in count sections * update sample app intro * DOCSP-41990: Authentication mechanisms (#139) * DOCSP-41990: Authentication mechanisms * client tabs * edits * edits * add info * reduce repetition * add section * fix link * MW feedback * fix * JM most feedback * move to code file * more JM edits * JM feedback 2 * DOCSP-41989: Security landing page (#149) * DOCSP-41989: Security landing page * more info * edits * snooty.toml * edits * RR feedback * JM feedback * DOCSP-41962 - Stable API (#117) Co-authored-by: Jeremy Mikola <[email protected]> * DOCSP-41992 Upgrade versions * toc * edits * how to upgrade sections * style * edit * edit * review comments * ref * Revise descriptions for server opening/closed events * DOCSP-43204: Connection landing page (#147) * DOCSP-43204: Connection landing page * toc edit * edits * remove compression * fix * sample app * snooty * JM feedback * replica set * JM feedback 2 * JM last feedback * DOCSP-43819: php 1.20 release * fix * DOCSP-41956: run a command * wip * formatting fix * JS PR fixes 1 * link fix * style fixes * JT tech review 1 * wip * JM tech review * tree * api links * links * JM tech review 2 * small fixes * add ext upgrade command * DOCSP-41995: transaction * wip * update code * NR PR fixes 1 * wip * add emphasis * add with_txn() method to api links * cxn string env * edit * JM tech review 1 * remove dupe sc * tech review * wrap fix * edit copy * DOCSP-41959 - Connection Options (#112) Co-authored-by: Nora Reidy <[email protected]> Co-authored-by: Jeremy Mikola <[email protected]> * DOCSP-43396: Cleanup (#151) * DOCSP-43396: Cleanup * quickstart fix * code fixes * edit * snooty * edit * code output * build log errors * another build fix * add info * upgrade guide to landing * fix * driver mentions * RR feedback * build fix * build fix * php directives --------- Co-authored-by: Mike Woofter <[email protected]> Co-authored-by: Rea Rustagi <[email protected]> Co-authored-by: Lindsey Moore <[email protected]> Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: rustagir <[email protected]> Co-authored-by: Brandon Ly <[email protected]> Co-authored-by: lindseymoore <[email protected]> Co-authored-by: Jeremy Mikola <[email protected]>
1 parent fdbbb6e commit d08acbc

File tree

150 files changed

+11267
-2014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+11267
-2014
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ build/*
33
build
44
*~
55
*giza.log
6-
source/*
76
backups/*
87
vendor/
98
composer.lock

netlify.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ name = "snooty-cache-plugin"
55
# set in your site’s Branches settings in the UI will inherit
66
# these settings.
77
[build]
8-
98
publish = "snooty/public"
109
command = ". ./build.sh"

snooty.toml

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name = "php-library"
22
title = "PHP Library Manual"
33

4-
intersphinx = ["https://www.mongodb.com/docs/manual/objects.inv"]
4+
intersphinx = [
5+
"https://www.mongodb.com/docs/manual/objects.inv",
6+
"https://www.mongodb.com/docs/drivers/objects.inv",
7+
"https://www.mongodb.com/docs/atlas/objects.inv",
8+
]
59

610
toc_landing_pages = [
711
"/reference/class/MongoDBClient",
@@ -17,10 +21,31 @@ toc_landing_pages = [
1721
"/reference/class/MongoDBModelCollectionInfo",
1822
"/reference/class/MongoDBModelDatabaseInfo",
1923
"/reference/class/MongoDBModelIndexInfo",
24+
"/get-started",
25+
"/connect",
26+
"/read",
27+
"/databases-collections",
28+
"/write",
29+
"/indexes",
30+
"/security",
31+
"/data-formats",
32+
"/upgrade",
2033
]
2134

35+
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
36+
2237
[substitutions]
2338
php-library = "MongoDB PHP Library"
2439

2540
[constants]
2641
php-library = "MongoDB PHP Library"
42+
extension-short = "PHP extension"
43+
mdb-server = "MongoDB Server"
44+
stable-api = "Stable API"
45+
library-short = "PHP library"
46+
driver-short = "{+library-short+}"
47+
api = "https://www.mongodb.com/docs/php-library/current/reference"
48+
php-manual = "https://www.php.net/manual/en"
49+
string-data-type = "``string``"
50+
bool-data-type = "``bool``"
51+
int-data-type = "``int``"

source/aggregation.txt

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
.. _php-aggregation:
2+
3+
====================================
4+
Transform Your Data with Aggregation
5+
====================================
6+
7+
.. facet::
8+
:name: genre
9+
:values: reference
10+
11+
.. meta::
12+
:keywords: code example, transform, computed, pipeline
13+
:description: Learn how to use the PHP library to perform aggregation operations.
14+
15+
.. contents:: On this page
16+
:local:
17+
:backlinks: none
18+
:depth: 2
19+
:class: singlecol
20+
21+
.. TODO:
22+
.. toctree::
23+
:titlesonly:
24+
:maxdepth: 1
25+
26+
/aggregation/aggregation-tutorials
27+
28+
Overview
29+
--------
30+
31+
In this guide, you can learn how to use the {+php-library+} to perform
32+
**aggregation operations**.
33+
34+
Aggregation operations process data in your MongoDB collections and
35+
return computed results. The MongoDB Aggregation framework, which is
36+
part of the Query API, is modeled on the concept of data processing
37+
pipelines. Documents enter a pipeline that contains one or more stages,
38+
and this pipeline transforms the documents into an aggregated result.
39+
40+
An aggregation operation is similar to a car factory. A car factory has
41+
an assembly line, which contains assembly stations with specialized
42+
tools to do specific jobs, like drills and welders. Raw parts enter the
43+
factory, and then the assembly line transforms and assembles them into a
44+
finished product.
45+
46+
The **aggregation pipeline** is the assembly line, **aggregation stages** are the
47+
assembly stations, and **operator expressions** are the
48+
specialized tools.
49+
50+
Aggregation Versus Find Operations
51+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
You can use find operations to perform the following actions:
54+
55+
- Select which documents to return
56+
- Select which fields to return
57+
- Sort the results
58+
59+
You can use aggregation operations to perform the following actions:
60+
61+
- Run find operations
62+
- Rename fields
63+
- Calculate fields
64+
- Summarize data
65+
- Group values
66+
67+
Limitations
68+
~~~~~~~~~~~
69+
70+
Consider the following limitations when performing aggregation operations:
71+
72+
- Returned documents cannot violate the
73+
:manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>`
74+
of 16 megabytes.
75+
- Pipeline stages have a memory limit of 100 megabytes by default. You can exceed this
76+
limit by creating an options array that sets the ``allowDiskUse`` option to ``true``
77+
and passing the array to the ``MongoDB\Collection::aggregate()`` method.
78+
79+
.. important:: $graphLookup Exception
80+
81+
The :manual:`$graphLookup
82+
</reference/operator/aggregation/graphLookup/>` stage has a strict
83+
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.
84+
85+
.. _php-aggregation-example:
86+
87+
Aggregation Example
88+
-------------------
89+
90+
.. note::
91+
92+
The examples in this guide use the ``restaurants`` collection in the ``sample_restaurants``
93+
database from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to create a
94+
free MongoDB Atlas cluster and load the sample datasets, see the :atlas:`Get Started with Atlas
95+
</getting-started>` guide.
96+
97+
To perform an aggregation, pass an array containing the pipeline stages to
98+
the ``MongoDB\Collection::aggregate()`` method.
99+
100+
The following code example produces a count of the number of bakeries in each borough
101+
of New York. To do so, it uses an aggregation pipeline that contains the following stages:
102+
103+
- :manual:`$match </reference/operator/aggregation/match/>` stage to filter for documents
104+
in which the ``cuisine`` field contains the value ``'Bakery'``
105+
106+
- :manual:`$group </reference/operator/aggregation/group/>` stage to group the matching
107+
documents by the ``borough`` field, accumulating a count of documents for each distinct
108+
value
109+
110+
.. io-code-block::
111+
:copyable:
112+
113+
.. input:: /includes/aggregation.php
114+
:start-after: start-match-group
115+
:end-before: end-match-group
116+
:language: php
117+
:dedent:
118+
119+
.. output::
120+
:visible: false
121+
122+
{"_id":"Brooklyn","count":173}
123+
{"_id":"Queens","count":204}
124+
{"_id":"Bronx","count":71}
125+
{"_id":"Staten Island","count":20}
126+
{"_id":"Missing","count":2}
127+
{"_id":"Manhattan","count":221}
128+
129+
Explain an Aggregation
130+
~~~~~~~~~~~~~~~~~~~~~~
131+
132+
To view information about how MongoDB executes your operation, you can
133+
instruct the MongoDB query planner to **explain** it. When MongoDB explains
134+
an operation, it returns **execution plans** and performance statistics.
135+
An execution plan is a potential way in which MongoDB can complete an operation.
136+
When you instruct MongoDB to explain an operation, it returns both the
137+
plan MongoDB executed and any rejected execution plans.
138+
139+
To explain an aggregation operation, construct a ``MongoDB\Operation\Aggregate`` object
140+
and pass the database, collection, and pipeline stages as parameters. Then, pass the
141+
``MongoDB\Operation\Aggregate`` object to the ``MongoDB\Collection::explain()`` method.
142+
143+
The following example instructs MongoDB to explain the aggregation operation
144+
from the preceding :ref:`php-aggregation-example`:
145+
146+
.. io-code-block::
147+
:copyable:
148+
149+
.. input:: /includes/aggregation.php
150+
:start-after: start-explain
151+
:end-before: end-explain
152+
:language: php
153+
:dedent:
154+
155+
.. output::
156+
:visible: false
157+
158+
{"explainVersion":"2","queryPlanner":{"namespace":"sample_restaurants.restaurants",
159+
"indexFilterSet":false,"parsedQuery":{"cuisine":{"$eq":"Bakery"}},"queryHash":"865F14C3",
160+
"planCacheKey":"D56D6F10","optimizedPipeline":true,"maxIndexedOrSolutionsReached":false,
161+
"maxIndexedAndSolutionsReached":false,"maxScansToExplodeReached":false,"winningPlan":{
162+
... }
163+
164+
Additional Information
165+
----------------------
166+
167+
To view a tutorial that uses the {+php-library+} to create complex aggregation
168+
pipelines, see `Complex Aggregation Pipelines with Vanilla PHP and MongoDB
169+
<https://www.mongodb.com/developer/products/mongodb/aggregations-php-mongodb/>`__
170+
in the MongoDB Developer Center.
171+
172+
MongoDB Server Manual
173+
~~~~~~~~~~~~~~~~~~~~~
174+
175+
To learn more about the topics discussed in this guide, see the following
176+
pages in the {+mdb-server+} manual:
177+
178+
- To view a full list of expression operators, see :manual:`Aggregation
179+
Operators </reference/operator/aggregation/>`.
180+
181+
- To learn about assembling an aggregation pipeline and to view examples, see
182+
:manual:`Aggregation Pipeline </core/aggregation-pipeline/>`.
183+
184+
- To learn more about creating pipeline stages, see :manual:`Aggregation
185+
Stages </reference/operator/aggregation-pipeline/>`.
186+
187+
- To learn more about explaining MongoDB operations, see
188+
:manual:`Explain Output </reference/explain-results/>` and
189+
:manual:`Query Plans </core/query-plans/>`.
190+
191+
.. TODO:
192+
Aggregation Tutorials
193+
~~~~~~~~~~~~~~~~~~~~~
194+
195+
.. To view step-by-step explanations of common aggregation tasks, see
196+
.. :ref:`php-aggregation-tutorials-landing`.
197+
198+
API Documentation
199+
~~~~~~~~~~~~~~~~~
200+
201+
To learn more about the methods discussed in this guide, see the
202+
following API documentation:
203+
204+
- :phpmethod:`MongoDB\Collection::aggregate()`
205+
- :phpmethod:`MongoDB\Collection::explain()`

source/compatibility.txt

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _php-compatibility:
2+
3+
=============
4+
Compatibility
5+
=============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: reference
16+
17+
.. meta::
18+
:keywords: backwards compatibility, versions, upgrade
19+
20+
MongoDB Compatibility
21+
---------------------
22+
23+
The following compatibility table specifies the recommended version or versions
24+
of the {+php-library+} and extension that you can use with a specific version of MongoDB.
25+
26+
The first column lists the version of the library and extension.
27+
28+
.. sharedinclude:: dbx/lifecycle-schedule-callout.rst
29+
30+
.. sharedinclude:: dbx/compatibility-table-legend.rst
31+
32+
.. include:: /includes/mongodb-compatibility-table-php.rst
33+
34+
For more information on how to read the compatibility tables, see our guide on
35+
:ref:`MongoDB Compatibility Tables <about-driver-compatibility>`.
36+
37+
Language Compatibility
38+
----------------------
39+
40+
The following compatibility table specifies the recommended version or versions
41+
of the {+php-library+} and extension that you can use with a specific version of PHP.
42+
43+
The first column lists the version of the library and extension.
44+
45+
.. include:: /includes/language-compatibility-table-php.rst
46+
47+
For more information on how to read the compatibility tables, see our guide on
48+
:ref:`MongoDB Compatibility Tables <about-driver-compatibility>`.
49+
50+
How to Get Help
51+
---------------
52+
53+
If you have questions about compatibility, visit the following resources for further guidance:
54+
55+
- Ask questions on our :community-forum:`MongoDB Community Forums <>`.
56+
- Visit our :technical-support:`Support Channels </>`.
57+
- File an issue or feature request in our issue tracker, JIRA, under one of the
58+
following projects:
59+
60+
- `PHPC - Extension <https://jira.mongodb.org/projects/PHPC/summary>`_
61+
62+
- `PHPLIB - Library <https://jira.mongodb.org/projects/PHPLIB/summary>`_

0 commit comments

Comments
 (0)