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

DOCSP-38344: remove environment variables from database config file #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,35 @@ in your sample app:
cp .env.example .env
```

### Configure your MongoDB Credentials
### Set the Default Connection Environment Variable

In your ``.env`` file, set or update the following variables, replacing the
``<connection string>`` placeholder with your MongoDB connection string:
Open the ``.env`` file in an editor and set the value of the ``DB_CONNECTION``
variable to ``mongodb`` as shown in the following example:

```
DB_CONNECTION=mongodb
DB_URI=<connection string>
```

### Make a Copy of the Example Environment File

Run the following command to use the example environment file
in your sample app:

```
cp .env.example .env
```

### Configure your MongoDB Credentials

In the ``.env`` file, replace the value of the ``DB_URI`` variable with your
MongoDB connection string.

For example, if your connection string is
"mongodb+srv://myUser:[email protected]/",
your ``DB_URI`` variable matches the following line:

```
DB_URI="mongodb+srv://myUser:[email protected]/"
```

If you need to create a MongoDB Atlas deployment, see the
Expand All @@ -90,6 +111,9 @@ If you already have a MongoDB Atlas deployment, see the
[Create a Connection String](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/quick-start/create-a-connection-string)
step of the Quick Start.

> [!NOTE]
> Make sure these variables in your ``.env`` file are undefined in the shell in which you run your application. Environment variables in the shell take precedence over the ones in the ``.env`` file.

### Start the PHP Built-in Webserver

To start the webserver, run the following command from the application root
Expand Down
4 changes: 2 additions & 2 deletions my-app/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
|
*/

'default' => env('DB_CONNECTION', 'mongodb'),
'default' => env('DB_CONNECTION'),

/*
|--------------------------------------------------------------------------
Expand All @@ -32,7 +32,7 @@
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('DB_URI', '<connection string>'),
'dsn' => env('DB_URI'),
'database' => 'sample_mflix',
],

Expand Down