Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Local development: environment configuration support?

Hi!

I would like to know if it's possible to set some configurations variables depending the enviroment in wich Vanilla is executed. I would like to set some vars on my local enviroment and others in production. I don't want to have two config.php files duplicated, one in my local enviroment and another one in production server.

Thanks!

Tagged:

Best Answer

Answers

  • x00x00 MVP
    edited February 2017

    typically this is done with a deployment flow. Such as if you used github and springloops.

    config would be excluded from this using .gitignore as would cache and uploads

    grep is your friend.

  • @x00 yeah, I'm using Git and I'm currently excluding cache and uploads folders and was looking a way to have one base config file and set some configs according the enviroment.

    @Linc thanks! I could really get use of that approach. I'm very used to work with Symfony and Laravel, and environments configuration is common, that's why I'm asking.

    Thanks both of you, guys!

  • I've used saveToConfig even on the theme level though it depends how early the config is required and the hook you use.

    bootstrap.early.php works well though you only want to save to config one better to use save=false after the config file is loaded that way you are loading on the fly. No need to write to file.

    grep is your friend.

  • nikoskipnikoskip
    edited March 2017

    @Linc I'm trying to set the database configuration using the bootstrap.early.php approach but is not working as I expected, for instance:

    saveToConfig('Database.Host', 'my_host', false);
    saveToConfig('Database.Name', 'my_db', false);
    saveToConfig('Database.User', 'my_user', false);
    saveToConfig('Database.Password', 'my_password', false);
    

    1.- If I comment the database config section from the config.php file it works and Vanilla gets connected, but... I can't do any change that affects the config.php file, like activate/deactivate plugins. Nothing get saved on the file.

    2.- If I just leave in blank the database configuration, instead of commented it, Vanilla can't connects, it's like it is reading the configuration directly from the file instead of memory.

    Thanks!

  • LincLinc Detroit Admin

    The config and the database both get loaded in the main bootstrap sequence without any intervening bootstrap.x moment being called, so I don't think it's possible to override that one via this method in the current release.

Sign In or Register to comment.