diff --git a/docs/fundamentals.txt b/docs/fundamentals.txt index 004930ad2..250e82efa 100644 --- a/docs/fundamentals.txt +++ b/docs/fundamentals.txt @@ -22,8 +22,7 @@ Fundamentals Learn how to use the {+odm-long+} to perform the following tasks: -- :ref:`Configure Your MongoDB Connection ` -- :ref:`Databases and Collections ` -- :ref:`Read Operations ` -- :ref:`Write Operations ` - +- :ref:`laravel-fundamentals-connection` +- :ref:`laravel-db-coll` +- :ref:`laravel-fundamentals-read-ops` +- :ref:`laravel-fundamentals-write-ops` diff --git a/docs/fundamentals/connection.txt b/docs/fundamentals/connection.txt index b1d11c58a..17b849ae9 100644 --- a/docs/fundamentals/connection.txt +++ b/docs/fundamentals/connection.txt @@ -7,6 +7,7 @@ Connections .. toctree:: /fundamentals/connection/connect-to-mongodb + /fundamentals/connection/connection-options .. contents:: On this page :local: @@ -17,9 +18,8 @@ Connections Overview -------- -Learn how to set up a connection from your Laravel application to a MongoDB -deployment and specify the connection behavior by using {+odm-short+} in the -following sections: +Learn how to use {+odm-short+} to set up a connection to a MongoDB deployment +and specify connection behavior in the following sections: - :ref:`laravel-connect-to-mongodb` - +- :ref:`laravel-fundamentals-connection-options` diff --git a/docs/fundamentals/connection/connection-options.txt b/docs/fundamentals/connection/connection-options.txt new file mode 100644 index 000000000..9d873a406 --- /dev/null +++ b/docs/fundamentals/connection/connection-options.txt @@ -0,0 +1,349 @@ +.. _laravel-fundamentals-connection-options: + +================== +Connection Options +================== + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: code example, data source name, dsn, authentication, configuration, options, driverOptions + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +Overview +-------- + +In this guide, you can learn about connection, authentication, and driver +options and how to specify them in your Laravel application's database +connection configuration. Connection options are passed to the {+php-library+}, +which manages your database connections. + +To learn more about the {+php-library+}, see the +`{+php-library+} documentation `__. + +This guide covers the following topics: + +- :ref:`laravel-connection-auth-options` +- :ref:`laravel-driver-options` + +.. _laravel-connection-auth-options: + +Connection and Authentication Options +------------------------------------- + +Learn how to add common connection and authentication options to your +configuration file in the following sections: + +- :ref:`laravel-connection-auth-example` +- :ref:`laravel-connection-auth-descriptions` + +.. _laravel-connection-auth-example: + +Add Connection and Authentication Options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can specify connection or authentication options in your Laravel web +application's ``config/database.php`` configuration file by using one of the +following methods: + +- Add the setting and value as an array item in the ``options`` array item. +- Append the setting and value as a query string parameter on the connection + string specified in the ``dsn`` array item. + +To specify an option in the ``options`` array, add its name and value as an +array item, as shown in the following example: + +.. code-block:: php + :emphasize-lines: 6-10 + + 'connections' => [ + 'mongodb' => [ + 'dsn' => 'mongodb+srv://mongodb0.example.com/', + 'driver' => 'mongodb', + 'database' => 'sample_mflix', + 'options' => [ + 'appName' => 'myLaravelApp', + 'compressors' => 'zlib', + 'zlibCompressionLevel' => 7, + ], + ], + ], + +To specify options as parameters in the connection string, use the following +query string syntax formatting: + +- Add the question mark character, ``?``, to separate the host information + from the parameters. +- Add the options by formatting them as ``