database = $database; } public function handle(Request $request, ConnectionInterface $httpConnection) { $this->database->query('SELECT * FROM users ORDER by created_at DESC')->then(function (Result $result) use ($httpConnection) { $httpConnection->send( respond_html($this->getView('server.users.index', ['users' => $result->rows])) ); $httpConnection->close(); }, function (\Exception $exception) use ($httpConnection) { $httpConnection->send(respond_html('Something went wrong: '.$exception->getMessage(), 500)); $httpConnection->close(); }); } }