Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

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!

Best Answer

Answers

  • x00x00 MVP
    edited February 27

    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 New
    edited March 17

    @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 Vanilla's Bard (and Lead Developer) Detroit Vanilla Staff

    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.