The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

Beginner to SLIM

manasavasishta's Avatar

manasavasishta

21 Apr, 2015 07:24 AM

Hi ,
 I am a newbie to slim. i am trying to implement a sample REST(http) API through slim framework which should return a JSON response.. But when i run it, i get the output something like this.. {"container":{}}. Any help pelase..Please find the attachment for the php code..

  1. 1 Posted by Liren on 21 Apr, 2015 12:28 PM

    Liren's Avatar

    The $app variable is the Slim application object.

    You should echo the JSON you want from the routes.

    $app->get('/', function () use ($app) {

    $someValues = [ 'some_key' => 'some_value', 'another_key' => 'another_value' ];

    echo json_encode($someValues);

    });

  2. 2 Posted by manasavasishta on 05 May, 2015 04:23 AM

    manasavasishta's Avatar

    Thanks for the reply Liren.. I modified the code according to your suggestions..
    But its displaying a ""blank page..Can you please suggest me how to find the error ...Please find the modified code in the attachment.

  3. 3 Posted by manasavasishta on 05 May, 2015 04:24 AM

    manasavasishta's Avatar

    Modified code index.php

  4. 4 Posted by manasavasishta on 13 May, 2015 01:32 PM

    manasavasishta's Avatar

    Thanks for the reply Liren,

                I modified the code according to your suggestions..
    But its displaying a ""blank page..Can you please suggest me how to find
    the error ...Please find the modified code in the attachment.

  5. 5 Posted by Paperpa on 13 May, 2015 04:06 PM

    Paperpa's Avatar

    Salute guys! Recently i wrote a review (here http://writebestessayforme.blogspot.com/ ) for essay writing service i use most often, and i welcome you to evaluate quality of my work :) Please check it out if you want and sorry for possible off-topic )

  6. 6 Posted by smilinglv on 02 Jun, 2015 11:58 AM

    smilinglv's Avatar

    what i can do is encourage you because i am new too .
    so let's go !! encourage each other !!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • index.php 297 Bytes

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac