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.

Accessing Vanilla / Garden Models from within another application

pavsidpavsid New
edited April 2015 in Vanilla 2.0 - 2.8

Hi, I want to confirm users (and eventually perform other functions) outside of the forum application, from within another application (our existing website).

Specifically, I'm looking to update the roles of a forum user once they confirm their email on the main website, and would like to use the UserModel::SaveRoles method.

What is the best way to include the Vanilla / Garden frameworks in another application?

I was looking at including the file /library/core/class.autoloader.php in the existing app, and then calling Gdn_Autoloader::Start(); but that depends on too many other includes, so i tried including /bootstrap.php but that too throws errors (include_once(Gdn.php): failed to open stream: No such file or directory)

I've defined APPLICATION and PATH_ROOT by the way, and my version of Vanilla is 2.1.9

Best Answer


  • pavsidpavsid New
    edited April 2015

    Ok, as our current website is using Zend Framework, I realised that I had to add Gdn_Autoloader to the Zend_Loader_Autoloader stack, before including the Vanilla bootstrap, like so..

            define('APPLICATION', 'Vanilla');
            define('PATH_ROOT', PUBLIC_PATH.'/community');
            Zend_Loader_Autoloader::getInstance()->pushAutoloader(array('Gdn_Autoloader', 'Lookup'), 'Gdn');

    Now I can access all the Garden / Vanilla Classes & Methods from within our external app.

    So I can do things like:

                    $UserModel = new UserModel();
                    $User = $UserModel->GetByEmail($account->email);
                    $UserModel->SaveRoles($User->UserID, $Roles, FALSE);
  • You can force load the framework. But do so sparingly. Consider the impact of double loading framework on every request.

    grep is your friend.

  • pavsidpavsid New
    edited April 2015

    Of course, I will only be doing this for performing updates to the Vanilla database so as to keep the local user profiles, and the vanilla user profiles synchronized.

    Not saying this is the best approach, as I don't know enough about Vanilla, but as there is no way currently to do it via the API then seems to be the best for me so far.

  • Therefore it could be event based.

    grep is your friend.

  • @x00 said:
    Therefore it could be event based.

    How do you mean? I'm performing updates to the Vanilla users from outside of the Vanilla app, so there are no Vanilla events.

  • I'm not talking about vanilla events.

    grep is your friend.

Sign In or Register to comment.