For a current project I am experimenting with XenForo and integrating CI (CodeIgniter) to build some extra functionality.
They are other areas of the site (not form specific). I just needed to be sure that the user (Visitor in XenForo terminology) was logged in, and if they were a super admin; while having access to libraries and the MVC of CI.
The set up for XenForo is fairly minor, there is none. Just install it and you're done, for this example it's installed in :
URL being :
I've installed (a default 1.7.3) in a separate directory for the moment just for ease of example (structure you site as needed, as always):
Example URL being :
Browsing to, gives us the obligatory all OK from the CI welcome controller :
I've shared the CI libary on gitHub : https://github.com/JeremyHutchings/xF_auth
As with any CI libary, download that and put the config/xf_auth.php config file in :
and the library/xf_auth.php in :
The two config settings in there being the URL for the forum and the path for the XenForo install, only the file path is used at the moment, so :
$config['xfAuth']['fileDir'] = '/var/www/ci';
No harm is setting the forum URL, I've just not written the functions to use it yet.
xF_auth is a wrapper for the XenForo_Visitor class, which is part of the XenForo core. It handles getting an instance of the Visitor and checking permissions for various actions and access.
With CI, XenForo and xF_auth all installed and configured, time to test CI.
The default welcome controller for CI is :
Edit this file and add the library load to the constructor :
class Welcome extends Controller
And then for the sake of testing, echo some debug from the controller opposed to creating a new view. That can be done once you get into development.
echo "You're logged in to XenForo !" .
" User id :: " . $this->xf_auth->getUserId() .
" username :: " . $this->xf_auth->get('username') .
" email :: " . $this->xf_auth->get('email');
echo "You are not logged in";
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
Now you will see :
(as long as you've logged into XF that is!)
You have now bootstrapped XF in another environment and can build functionality else where on the site using familiar CI MVC techniques.
XenForo at time of writing is in beta, and approaching RC. Though having a library abstract the bootstrapping means that any changes can be hidden from a CI application and implementation.
Usergroups - The next functions to be added will check what usergroups and permissions the user/Visitor has so the C of MVC in CI can build the views correctly.
Templates - Being able to call XF templates within CI (view integration), though using the XF context and phrasing is a goal.