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

Environment::get('development'); returning empty array #1177

Closed
DMcP89 opened this issue Mar 25, 2015 · 5 comments
Closed

Environment::get('development'); returning empty array #1177

DMcP89 opened this issue Mar 25, 2015 · 5 comments

Comments

@DMcP89
Copy link

DMcP89 commented Mar 25, 2015

I am having some trouble with the Environment::get() method. From my understanding of the documentation found here: http://li3.me/docs/lithium/core/Environment::get() passing in the string of the name of an environment should return an array of the entire configuration.

I have my Connections setup as so:

 Connections::add('default', array(
        'development' => array(
           'type' => 'MongoDb',
           'host' => 'localhost',
          'database' => 'web_app'
        )
  ));

However when i call Environment::get('development'); it returns an empty array. Is there something I am missing? I tried calling Environment::get('default'); and it gave me a null.

I have set my environment to 'development' in my bootstrap file:

lithium\core\Environment::set('development');

I am not sure what else could be going wrong.

@jails
Copy link
Contributor

jails commented Mar 25, 2015

It's probably because the environment is lazily initialized here https://github.com/UnionOfRAD/framework/blob/f3b1c20a7228a529ec59b582fc033f9911b9551a/app/config/bootstrap/action.php#L42 by default in the famework repo.
This explains why it's not available at a bootstrap level.

@DMcP89
Copy link
Author

DMcP89 commented Mar 25, 2015

I'm not sure I follow you. I tried removing the Environment::set call you mentioned but got the same results.

I did take a look at the Environment class in lithium/core/Environment.php and noticed this:

    protected static $_configurations = array(
    'production' => array(),
    'development' => array(),
    'test' => array()
     );

Should I be setting up my connections here instead and not in app/config/bootstrap/connections.php?

@jails
Copy link
Contributor

jails commented Mar 25, 2015

Don't remove it, just move the initialization call before using it in the bootstrap file.

@mariuswilms
Copy link
Member

Closing as this is not a bug.

@DMcP89
Copy link
Author

DMcP89 commented Mar 25, 2015

@jails I am a little confused here, I put actions.php back to its orignal form and removed the Environment::Set call I was making in my bootstrap file. My connections.php file is still setup as described above, but now when I go to my site I get this error:

Fatal error: Uncaught exception 'lithium\core\ConfigException' with message 'No adapter set for configuration in class lithium\data\Connections

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

3 participants