I have a folder structure like this :
|/app
|-/db/users.php
|/Slim
|/vendor
|index.php
and inside index.php
:
require 'vendor/autoload.php';
$app = new Slim\App();
$app->get('/{action}/{type}/{props}', function ($request, $response, $args) {
$jenis_user = strtolower($args['type']);
$aksi = strtolower($args['action']);
$prop = strtolower($args['props']);
$target_loc = "";
if($aksi == 'get'){
// the parameter is using the following format
// action=XX&type=YY&props=ZZ;
$target_loc = "./app/db/users.php?action=". $aksi . "&type=" . $jenis_user . "&props=" . $prop ;
// #Tips :: data extracted are in Array Format ::
$file = file_get_contents($target_loc);
$response->write(json_encode($file));
}
return $response;
});
My purpose is to get an integer value returned if I use the following path into the browser:
http://api.myweb.com/get/seller/totalNumber
But it seems the way I wrote the routing of passing parameter is mistaken: I got a warning of
Warning: file_get_contents(./app/db/users.php?action=get&type=seller&props=totalnumber): failed to open stream
How could I fix it?