.gitignore The Database File In Laravel
I'm sharing my Laravel project with another co-worker. But he's using Mac and I'm using Windows. So there's specific change to his database.php
file which is only for Mac mamp. How can I ignore this file from the version controlling? Should I add this file path in the .gitignore
at the root directory?
Answer
For configs I use .env.development.php
. my file looks like the following
<?php
return [
'ENV' => 'development',
'DB_USERNAME' => 'db_dev_username',
'DB_PASSWORD' => 'db_password',
'DB_NAME' => 'dev_db'
];
Inside this file I have my database settings. then I create /app/config/development folder. inside that is settings i want running. I would have a database.php file in there and it looks like
return array(
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
);
/bootstrap/start.php - it has this inside it. if it can't find the value of ENV, it defaults to development.
$env = $app->detectEnvironment(function()
{
return getenv('ENV') ?: 'development';
});
laravel should come with .gitignore that includes an entry for the .env.* files so it won't push it.
my .gitignore file looks like this:
/bootstrap/compiled.php
/vendor
composer.phar
composer.lock
.DS_Store
Thumbs.db
app/config/local
app/config/development
.env.*.php
Related Questions
- → Authenticate with a cookie using laravel 5.1 and jwt
- → Finding a specific GitLab tag from PHP
- → React: How to publish page on server using React-starter-kit
- → babel-loader, webpack, ES2015 modules: "Element type is invalid"
- → Create a function-attribute of a function, which is, in its turn, a method of an object literal
- → Model Validation in laravel 5.1 not working
- → GIT fatal: loose object
- → Laravel validation required rule not working
- → Axios array map callback
- → Where does this `webpack://` come from for `webpack-dev-middleware`?
- → error when trying to modify project in laravel forge
- → GitHub Pages and Jekyll content duplication and SEO issues
- → Use Laravel repositories with Datatables