Skip to content

Commit

Permalink
Merge pull request #3 from gyanendra-baghel/fix/add-env-variable
Browse files Browse the repository at this point in the history
Feat: Env variables added
  • Loading branch information
gyanendra-baghel authored May 18, 2024
2 parents c7a8e1a + ceea6ef commit c79b4be
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DB_HOST=localhost
DB_NAME=gyan
DB_USERNAME=root
DB_PASSWORD=root
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.phar
/vendor/
.env

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AuthController extends Controller
public function __construct()
{
parent::__construct();
$this->conn = new \PDO("mysql:host=localhost;dbname=gyan", "root", "");
$this->conn = new \PDO("mysql:host=".$_ENV["DB_HOST"].";dbname=".$_ENV["DB_NAME"], $_ENV["DB_USERNAME"], $_ENV["DB_PASSWORD"]);
}
public function search($req)
{
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"require": {
"ryxo/framework": "^0.0.1"
"ryxo/framework": "^0.0.1",
"symfony/dotenv": "^7.0"
}
}
}
76 changes: 75 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

require_once BASE_PATH . '/vendor/autoload.php';

$dotenv = new Symfony\Component\Dotenv\Dotenv();
$dotenv->load(BASE_PATH.'/.env');

use Ryxo\Route;
use App\controllers\SiteController;
Expand Down

0 comments on commit c79b4be

Please sign in to comment.