0

I'm developing laravel proect with git to test my proect to server, my .env is set to local setting for database setting. when i push my laravel proect with git (with .env file), i must resetting my .env at my server.

Can i make a setting that can detect when it's at sserver it use server setting, when i artisan at local, it's using local setting?

so i don't need to change my .env anymore, just need set it at the first time, and it can used forever, i don't need to change the setting again at server

Could i?

yudijohn
  • 1,248
  • 3
  • 19
  • 43
  • 2
    you can ignore the `.env` file so git won't push it. and make new env at your server (one time job). so everytime you push, the env is not replace by your local .env – ssuhat Jan 11 '16 at 08:48
  • The .env file is not meant for production use, set environment variables instead. This can be done in your apache/nginx configuration. The .env file is only a development help to quickly set variables without reconfiguring your web server. – sisve Jan 11 '16 at 12:23

1 Answers1

1

The .env file, as the name suggests, is environment dependent and it is not supposed to be tracked with git. When you deploy the project on your server you just need to create a new .env file at the server.

Laravel Environment Config

joruro
  • 827
  • 1
  • 6
  • 10
  • 1
    The .env file is not meant for production use, set environment variables instead. The linked Laravel documentation only mentions .env for configuring your development environment differently from your production (and forgets about how to configure the production environment). There are known threading (read: potential security) related issues with .env and some hosting configurations. https://github.com/vlucas/phpdotenv/issues/76#issuecomment-87252126 – sisve Jan 11 '16 at 12:22