Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sharing .env files with team members?

Just starting to dabble using laravel, and they encourage the use of .env files for development.

Its recommended that you do not commit these files into version control, so when a new developer on your team comes to start working on the project, they will not have this file.

The Question

Have I missed something, or are we just expected to effectively email the configured .env files to other developers, for them to drop into their copy of the project so that they can work on it, without finding out the database details etc and adding in theirselves?? Especially when you might be using a vagrant setup with provisioning and the database details are identical, and they'll use the same url. Nothing needs to be configured for them because you're using a controlled environment.

Thanks

like image 578
owenmelbz Avatar asked Dec 24 '22 10:12

owenmelbz


1 Answers

.env file do not recommend to add in any VCS instead of that you can create for example .env.example. And set in this file all variable which need your project. Actually, Laravel has this file and you can edit it and add to your VCS. When your team have a new member, he just copy .env.example to .env and set values according to his settings

Edit
You could set command in your composer.jsonfile, after composer install copy .env.example to .env where in your .env.example stores all your setting.

 "post-install-cmd": [
        "php artisan clear-compiled",
        "php -r \"copy('.env.example', '.env');\"",
        "php artisan optimize"
    ],

It give you a flexibility to change values without affecting setting of your team.

like image 120
xAoc Avatar answered Dec 31 '22 02:12

xAoc