Last active
August 29, 2015 14:01
-
-
Save dmouse/f63f285301cec89fbe0f to your computer and use it in GitHub Desktop.
Symfony Reponse examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "dmouse/response", | |
| "description": "Response sample", | |
| "require": { | |
| "symfony/http-foundation": "2.4.*" | |
| }, | |
| "license": "MIT", | |
| "authors": [ | |
| { | |
| "name": "David Flores", | |
| "email": "[email protected]" | |
| } | |
| ], | |
| "minimum-stability": "dev" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\Response; | |
| require __DIR__ . '/vendor/autoload.php'; | |
| $response = new Response(); | |
| $response->setContent('Hello world'); | |
| $response->setMaxAge(10); | |
| #echo $response->send(); | |
| $response->send(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\Response; | |
| require __DIR__ . '/vendor/autoload.php'; | |
| $response = new Response(); | |
| $response->setContent('Hello world'); | |
| $response->send(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\Response; | |
| require __DIR__ . '/vendor/autoload.php'; | |
| $response = new Response(); | |
| echo $response->send(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\Response; | |
| require __DIR__ . '/vendor/autoload.php'; | |
| $response = new Response(); | |
| $response->setContent(json_encode(['message'=>'Hello world'])); | |
| $response->headers->set('Content-Type', 'application/json'); | |
| $response->setMaxAge(10); | |
| #echo $response->send(); | |
| $response->send(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\JsonResponse; | |
| require __DIR__ . '/vendor/autoload.php'; | |
| $response = new JsonResponse(); | |
| $response->setData([ | |
| 'data' => 123 | |
| ]); | |
| # echo $response->send(); | |
| $response->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment