So I'm extending the XenForo "SDK" to make an integration with an app I'm working on like so;
$dir = __DIR__;
require $dir . '/src/XF.php';
XF::start($dir);
$app = XF::setupApp('XF\Pub\App');
$app->start();
$user = XF::visitor();
However, there is a bit of a problem. If I use var_dump($user)
, it outputs everything but prefixes everything with the class and its type which isn't what I want. E.G
object(XF\Entity\User)#435 (15) { ["_uniqueEntityId":"XF\Mvc\Entity\Entity":private]=> int(5) ["rootClass":protected]=> string(14) "XF\Entity\User" ["_useReplaceInto":protected]=> bool(false) ["_newValues":protected]=> array(0) { } ["_values":protected]=> array(34) { ["user_id"]=> int(1) ["username"]=> string(5) "admin" ["email"]=> string(21) "placeholder" ["custom_title"]=> string(0) "" ["language_id"]=> int(0) ["style_id"]=> int(0) ["timezone"]=> string(13) "Europe/London" ...
But, if I just return $user
, I only get the class name as a return like so;
XF:User[1]
Basically, I'm trying to return the user instance as JSON with all the information that var_dump
provides, but without all the weird prefix casting.
If I access the properties directly, e.g $user->email
, it works, but I feel like there must be a better way than me just repeating that for each property in the whole instance.
Sorry if this is a basic question. I tried searching and couldn't find much on it.