Advent of code 2016/1
Ajax Direct

Answer

Part 1 :
Part 2 :
$city   = grid();
$me     = xy();
$facing = "up";

foreach ($input->split(",")->map("trim") as $direction) {
    $d = $direction[0];
    $c = substr($direction, 1);
    $facing = facing($facing, direction($d));
    $me->direction($facing, $c);
}

// ==================================================
// > PART 1
// ==================================================
$solution_1 = $me->manhattan([0, 0]);

// ==================================================
// > PART 2
// ==================================================
$solution_2 = xy(json_decode(
    $me->getFullHistory()->map("json_encode")->duplicates(2)->first())
)->manhattan([0, 0]);