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

FIX added function exists around env declaration #1

Closed
wants to merge 3 commits into from

Conversation

bartjuh4
Copy link

@bartjuh4 bartjuh4 commented May 4, 2016

Some other packages also using the env function and have their own declaration, this will cause a fatal error.

@oscarotero
Copy link
Owner

Hello.
This pull request includes some changes in the composer.json file like renamed the project and deleted the author :)
Anyway, this is the reason of why this package has the static method Env::init() to include the global function, so this should be fixed simply with this code:

if (!function_exists('env')) {
    Env::init();
}

In some cases including the env() is problematic (some libraries have their own env() function with a different purpose than this one, for example deployer), so you can use Env::get() instead.

@bartjuh4
Copy link
Author

bartjuh4 commented May 4, 2016

I'm sorry for the commits with changes in the composer.json. This was not intented.

@oscarotero
Copy link
Owner

I know, don't worry 😃
I'm not sure whether is good idea to include the function_exists inside the Env::init() or not. Some alternatives:

//Create a specific function
Env::initIfNotExists();

//Or using an argument to check
Env::init(true);

@oscarotero oscarotero closed this in 1cdc4ad May 8, 2016
@oscarotero
Copy link
Owner

Finally I've included the function_exists checking and Env::init() returns true or false if the function has been registered or not.
Thanks for reporting this.

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

Successfully merging this pull request may close these issues.

2 participants