Skip to content

Commit f3851e7

Browse files
author
ahmadhuss
committed
docs: Update README.md
1 parent 50f3d79 commit f3851e7

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,81 @@ It will automatically find your `.env` file and place the base 64 value in the f
2222
APP_KEY=base64:T0huMR5Wx9EoDmjTxniKTofHD/7cOiDeVVD9eTKuCa0=
2323
```
2424

25+
## Additional Note:
26+
As you can see it is necessary to create the `.env` file in your local to bootstrap the project. But `Laravel` contains 2 methods to connect to the database server.
27+
28+
- Use of the `.env` variables *(I prefer this one)*
29+
- Use of the file located at the `config/database.php`
30+
31+
32+
33+
## Use of the `.env` variables:
34+
35+
When you create this file with copy paste credentials you can see default the database variables are written something like this:
36+
```
37+
DB_CONNECTION=mysql
38+
DB_HOST=127.0.0.1
39+
DB_PORT=3306
40+
DB_DATABASE=test_app
41+
DB_USERNAME=root
42+
DB_PASSWORD=
43+
```
44+
45+
You can edit values according to your own database personal preference. I am using Postgres in this case.
46+
47+
## Use of the file located at the `config/database.php`
48+
49+
**Note:** When Laravel bootstraps the project it gives priority to the `.env` file as compared to `config/**` files. You can see `config/database` file contains an associated array with default database settings like this.
50+
51+
```
52+
return [
53+
54+
'default' => env('DB_CONNECTION', 'mysql'),
55+
'connections' => [
56+
'mysql' => [
57+
'driver' => 'mysql',
58+
'url' => env('DATABASE_URL'),
59+
'host' => env('DB_HOST', '127.0.0.1'),
60+
'port' => env('DB_PORT', '3306'),
61+
'database' => env('DB_DATABASE', 'forge'),
62+
'username' => env('DB_USERNAME', 'forge'),
63+
'password' => env('DB_PASSWORD', ''),
64+
'unix_socket' => env('DB_SOCKET', ''),
65+
'charset' => 'utf8mb4',
66+
'collation' => 'utf8mb4_unicode_ci',
67+
'prefix' => '',
68+
'prefix_indexes' => true,
69+
'strict' => true,
70+
'engine' => null,
71+
'options' => extension_loaded('pdo_mysql') ? array_filter([
72+
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
73+
]) : [],
74+
],
75+
]
76+
]
77+
```
78+
79+
You can only use these settings if variables from the `.env` file will be deleted. Otherwise, Laravel gives priority to `.env` variables.
80+
81+
Delete the variables from the `.env`:
82+
83+
84+
~~DB_CONNECTION=mysql~~
85+
~~DB_HOST=127.0.0.1~~
86+
~~DB_PORT=3306~~
87+
~~DB_DATABASE=test_app~~
88+
~~DB_USERNAME=root~~
89+
~~DB_PASSWORD=~~
90+
91+
Lastly, Update the `config/database.php` with your database server settings:
92+
93+
```
94+
'default' => env('DB_CONNECTION', 'pgsql')
95+
'database' => env('DB_DATABASE', 'shop_test'),
96+
'username' => env('DB_USERNAME', 'postgres'),
97+
'password' => env('DB_PASSWORD', 'a')
98+
```
99+
25100
# Database
26101
In my case I am using **Postgres** and inside `.env` file my database server creditenials are:
27102
```
@@ -37,3 +112,7 @@ However, your main server and database server get started.
37112

38113
# Template I am using
39114
[Download Link](https://startbootstrap.com/template/shop-homepage)
115+
116+
# Deployment
117+
[Heroku](https://www.heroku.com)
118+

0 commit comments

Comments
 (0)