common Posted July 11, 2014 Share Posted July 11, 2014 Hi everyone. I am looking at creating my application's back end with PHP, which returns all data with Jason or simplexml. I have tried Slim once, but think there should be something easier to use. Can anyone give me suggestions on what I can use which is easy to catch on, and maybe an example? Appreciate it. Kind regards Quote Link to comment https://forums.phpfreaks.com/topic/289749-json-service-for-back-end/ Share on other sites More sharing options...
trq Posted July 12, 2014 Share Posted July 12, 2014 Slim is probably as simple as its going to get for the sort of thing. Quote Link to comment https://forums.phpfreaks.com/topic/289749-json-service-for-back-end/#findComment-1484779 Share on other sites More sharing options...
common Posted July 14, 2014 Author Share Posted July 14, 2014 Hi Thanks for your reply. I tried looking at the website, but had some difficulty to understanding/initialize the Slim app object. So I am not sure if I am doing it correctly now: Can you maybe just help me where I go wrong, or what developing pattern I should follow. Here is something I have already. <?php header("Content-Type: application/json"); require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); $app->get('/users', 'findAll'); $app->get('/users/:id', 'findById'); $app->post('/user/new', 'create'); $app->put('/user/update', 'update'); $app->run(); function create() { $app = new \Slim\Slim(); $request = $app->request; //Slim::getInstance()->request(); $user->json_decode($request->getBody(),true); $id = .... echo $id; } function update() { $request = Slim::getInstance()->request(); $user = json_decode($request->getBody()); ... } function findAll() { $userarr =... echo json_encode($userarr); } function findById($id) { $user = ... echo json_encode($user); } ?> Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/289749-json-service-for-back-end/#findComment-1484978 Share on other sites More sharing options...
Rifts Posted July 28, 2014 Share Posted July 28, 2014 you dont have to use a framework to use json. Quote Link to comment https://forums.phpfreaks.com/topic/289749-json-service-for-back-end/#findComment-1486358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.