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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -