Valet: Idea: Valet environment variables

Created on 15 Sep 2016  路  4Comments  路  Source: laravel/valet

I have been using valet for a while and love it! I think it would pretty damn cool for Valet to automatically load any environment variables contained in a .env file into the virtual host declaration within caddy for the site. It could even be an optional command such as valet load:env or something like that. Does anyone else think this is a feature worthy of being worked on? If so, I might take it up and do a PR

Most helpful comment

This could be beneficial.

I currently just edit my .valet/Caddy/foo.dev file directly to add an environment var to the couple sites that need it:

    fastcgi / 127.0.0.1:9000 php {
        index server.php
+       env VARNAME value
    }

... but of course that requires a manual edit, and remembering the syntax, and remembering the right line to put it on.

All 4 comments

This could be beneficial.

I currently just edit my .valet/Caddy/foo.dev file directly to add an environment var to the couple sites that need it:

    fastcgi / 127.0.0.1:9000 php {
        index server.php
+       env VARNAME value
    }

... but of course that requires a manual edit, and remembering the syntax, and remembering the right line to put it on.

I think it could be cool. For each laravel site, I open up the dotenv and setup:

  • my local mariadb user and password
  • database equal to the directory name
  • set redis for the session and cache drivers
  • set local redis password

Since these are shared across all of my valet sites I think it makes sense.

I too, used to edit the Caddyfile, but since Valet migrated to nginx, I lost the ability to do it.
Plus, creating files for the variables outside the codebase itself, was a little bit off for me.
Anyway, I've been using this locally for a while now, and I made a PR out of it.
https://github.com/laravel/valet/issues/473

Closing; duplicated by #473, which is (potentially) solved by #474.

Was this page helpful?
0 / 5 - 0 ratings