Accessing Vanilla / Garden Models from within another application
![pavsid](https://secure.gravatar.com/avatar/c36e792d22e5d4850ff9b4aea8687665/?default=https%3A%2F%2Fvanillicon.com%2Fa2f0b808c3a93b58631a72e32a35ea02_100.png&rating=g&size=100)
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
-
Shadowdare MVP
Check out this discussion for an example of how to include the Garden framework outside of the Vanilla directory: http://vanillaforums.org/discussion/comment/195082/#Comment_195082
Add Pages to Vanilla with the Basic Pages app
5
Answers
Check out this discussion for an example of how to include the Garden framework outside of the Vanilla directory: http://vanillaforums.org/discussion/comment/195082/#Comment_195082
Add Pages to Vanilla with the Basic Pages app
Ok, as our current website is using Zend Framework, I realised that I had to add
Gdn_Autoloader
to theZend_Loader_Autoloader
stack, before including the Vanilla bootstrap, like so..Now I can access all the Garden / Vanilla Classes & Methods from within our external app.
So I can do things like:
You can force load the framework. But do so sparingly. Consider the impact of double loading framework on every request.
grep is your friend.
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.
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.