In XF1, several lines were required to bridge. In XF2, only four lines are required.
Create a file named connectXenForo2.php and add the following contents.
PHP:
<?php
/** @var $fileDir */
$fileDir = '/Users/layneheiny/Documents/Sites/xf2';
require($fileDir . '/src/XF.php');
XF::start($fileDir);
$app = XF::setupApp('XF\Pub\App');
Now create a file named user.php
PHP:
<?php
require_once '../connectXenForo2.php';
require_once '../connectDump.php';
$finder = \XF::finder('XF:User');
$user = $finder->where('user_id', 1)->fetchOne();
dd($user);
And the array is returned. BEAUTIFUL.
PS. My connectDump.php
PHP:
<?php
/**
* Filename: connectDump.php
*
* Return information about a variable.
* Include this file to the top of phptest files.
*
* Usage: dd($nameOfVariable);
*/
function dd($variable) {
if ( is_array( $variable ) ) {
echo '<pre>';
print_r($variable);
echo '</pre>';
return true;
}
return var_dump($variable);
}
// End connectDump.php