Managed to setup the Restful API tutorial on an Ec2 server.
when I access the first function I get the following:
[Sun May 17 07:11:41.406058 2015] [:error] [pid 8393] [client XXX.XXX.XXX.XXX:51964] PHP Notice: Undefined variable: app in /var/XXXX/XXXX/XXXX/index.php on line 13 [Sun May 17 07:11:41.406086 2015] [:error] [pid 8393] [client XXX.XXX.XXX.XXX:51964] PHP Notice: Trying to get property of non-object in /var/XXXX/XXXX/XXXX/index.php on line 13 [Sun May 17 07:11:41.406092 2015] [:error] [pid 8393] [client XXX.XXX.XXX.XXX:51964] PHP Fatal error: Call to a member function executeQuery() on a non-object in /var/XXXX/XXXX/XXXX/index.php on line 13
Code for my index.php is as follows:
use Phalcon\Mvc\Micro; use Phalcon\Http\Response;
$app = new Micro();
//Retrieves all organisations $app->get('/api/organisation', function() {
$phql = "SELECT * FROM XXXXXXXX ORDER BY XXXXXXXXX";
$organisation = $app->modelsManager->executeQuery($phql);
$data = array();
foreach ($organisation as $org) {
$data[] = array(
'id' => $org->XXXXXX,
'name' => $org->XXXXXXX,
);
}
Any help would be much appreciate. I have checked that the compile and install went ok.
Thanks
iQiniso
echo json_encode($data);
});