-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[5.8] Database Connection URLs #5189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! As I'm not a really good english speaker, I was afraid of doing it... 😅
I've added some explanations, and let you correct them if needed.
#### The `url` Option | ||
|
||
Using Heroku or another "cloud" database provider, you may need to specify the database connection URL. The `url` option is an *optional* value that can be used to specify the URL of your database connection. You can configure the database connection URL by setting the `DATABASE_URL` value within your `.env` environment file. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe should we add more explanations, and some examples?
Scheme: | |
DATABASE_URL=driver://username:password@host:port/database?options | |
Examples: | |
DATABASE_URL=sqlite:///path/to/database.sqlite | |
DATABASE_URL=sqlite:///:memory: | |
DATABASE_URL=mysql://forge:@localhost/forge?charset=UTF-8 | |
All the non null parts of the url will overwrite the standard config keys. | |
As an example, this config: | |
[ | |
'url' => 'mysql://root:pass@db/local', | |
'driver' => 'mysql', | |
'host' => '127.0.0.1', | |
'port' => '3306', | |
'database' => 'forge', | |
'username' => 'forge', | |
'password' => '', | |
'charset' => 'utf8mb4', | |
'collation' => 'utf8mb4_unicode_ci', | |
'strict' => true, | |
'options' => ['foo' => 'bar'], | |
] | |
Will be read as: | |
[ | |
'driver' => 'mysql', | |
'host' => 'db', | |
'port' => '3306', | |
'database' => 'local', | |
'username' => 'root', | |
'password' => 'pass', | |
'charset' => 'utf8mb4', | |
'collation' => 'utf8mb4_unicode_ci', | |
'strict' => true, | |
'options' => ['foo' => 'bar'], | |
] | |
@@ -73,6 +73,10 @@ You only need to place items in the `read` and `write` arrays if you wish to ove | |||
|
|||
The `sticky` option is an *optional* value that can be used to allow the immediate reading of records that have been written to the database during the current request cycle. If the `sticky` option is enabled and a "write" operation has been performed against the database during the current request cycle, any further "read" operations will use the "write" connection. This ensures that any data written during the request cycle can be immediately read back from the database during that same request. It is up to you to decide if this is the desired behavior for your application. | |||
|
|||
#### The `url` Option | |||
|
|||
Using Heroku or another "cloud" database provider, you may need to specify the database connection URL. The `url` option is an *optional* value that can be used to specify the URL of your database connection. You can configure the database connection URL by setting the `DATABASE_URL` value within your `.env` environment file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Heroku or another "cloud" database provider, you may need to specify the database connection URL. The `url` option is an *optional* value that can be used to specify the URL of your database connection. You can configure the database connection URL by setting the `DATABASE_URL` value within your `.env` environment file. | |
Using Heroku or another "cloud" database provider, you may need to specify the database connection URL. The `url` option is an *optional* value that can be used to specify the URL of your database connection. You can configure the database connection URL by setting the `DATABASE_URL` value within your `.env` environment file or in your system environment. |
I don't think this makes a lot of sense nested under "Read / Write" connections since it has nothing to do with that. Also I think an example as suggested could be useful. |
I massaged it a bit and moved it. |
PR adds note about the
url
option within the connection configuration.laravel/framework#28308