Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a smartLoad() method #74

Closed
rentalhost opened this issue Mar 15, 2015 · 1 comment
Closed

Create a smartLoad() method #74

rentalhost opened this issue Mar 15, 2015 · 1 comment

Comments

@rentalhost
Copy link

With it, you will not need pass the .env directory, it'll transverse back directory until find the first .env (like the jQuery.closest() does). For instance:

/home/username/www/path/to/my/bootstrap.php <-- smartLoad() here
/home/username/.env

smartLoad() will transverse directories until find the first accessible .env file, or will fail.

/home/username/www/path/to/my/.env <-- fail
/home/username/www/path/to/.env <-- fail
/home/username/www/path/.env <-- fail
/home/username/www/.env <-- fail
/home/username/.env <-- found

Signature:

Dotenv::smartLoad(string $startDir = __DIR__, string $filename = ".env")
:: Can thrown InvalidArgumentException:
:: Dotenv: Environment file [filename] not found or not readable from [startDir]. 

It'll help a lot because you will not need specifiy two directories to local env and remote env, it'll load file smartly for you or thrown an exception if no .env is found.

Alternativaly, just turns load($path) optional. If you omit it, it'll transverse from caller path.

@vlucas
Copy link
Owner

vlucas commented May 30, 2015

I don't want Dotenv to be doing this right now. You should always specify the path to your .env file.

@vlucas vlucas closed this as completed May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants