Get visitor info with Phalcon

JackBauer

Member
I have a website that uses Phalcon. The directory structure looks like this:
Code:
mysite
-- app
---- controllers
------ IndexController.php
-- forums
---- (XenForo stuff here)

I'm trying to register a visitor component with the Phalcon IoC container like this:
Code:
$di->set('visitor', function () {
  \XenForo_Autoloader::getInstance()->setupAutoloader('/mysite/forums/library');
  \XenForo_Application::initialize('/mysite/forums/library', '/mysite/forums', true, array('resetOutputBuffering' => false));
  \XenForo_Session::startPublicSession();

  $visitor = \XenForo_Visitor::getInstance();

  return $visitor;
});

Then my controller action is pretty simple:
Code:
public function indexAction()
{
  echo $this->visitor->get('username');
}

The problem is this displays absolutely nothing on the page. There are no errors in XenForo logs, Apache logs or otherwise. If I put the guts of that function in my controller action it works just fine:
Code:
public function indexAction()
{
  \XenForo_Autoloader::getInstance()->setupAutoloader('/mysite/forums/library');
  \XenForo_Application::initialize('/mysite/forums/library', '/mysite/forums', true, array('resetOutputBuffering' => false));
  \XenForo_Session::startPublicSession();

  $visitor = \XenForo_Visitor::getInstance();

  echo $visitor->get('username');
}

Anyone know anything about Phalcon that can help me with this?
 
Nevermind. I forgot to put

Code:
<?php echo $this->getContent(); ?>

in my view. I figured this out after I tried removing the view entirely, which worked too.
 
Top Bottom