Create rest api in slim php -
Create rest api in slim php -
im trying create rest api in slim.php. want 2 function. 1 retrieving records table json. , 1 retrieving record id.
this far index/api file looks below. how connects database? how homecoming json?
<?php require 'slim/slim.php'; \slim\slim::registerautoloader(); $app = new \slim\slim(); $app->get( '/', function () { echo "hola!"; } ); $app->run();
i have manage going. result back, not pure json. can't see boy in console. tjo gets written out in browser. current code:
$app->get('/', function () { $db = connect_db(); $result = $db->query( 'select * test;' ); while ( $row = $result->fetch_array(mysqli_assoc)){ $data[] = $row; } echo json_encode($data); }); php rest slim
Comments
Post a Comment