symfony/symfony — pull request #12120 by weaverryan (2014-10-03 20:52:53+00:00)
Title: Adding createResponse and createJsonResponse to Controller

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | --
| License | MIT
| Doc PR | not yet :angel:

Hi guys!

Apologies for the late edition! This introduces 2 shortcut Controller methods:

* `createResponse`
* `createJsonResponse`

Since Symfony requires you to return a Response object (not just a string), creating simple pages - especially for beginners - takes a bit more effort because you need to add the long `use` statement to return `Hello World`. I think this makes life much easier, without obviously sacrificing the nice reality that we always return a Response.

**Before**:
```php
use Symfony\Component\HttpFoundation\Response;

public function helloAction()
{
return Response('Hello world!');
}
```

**After**:
```php
public function helloAction()
{
return $this->createResponse('Hello world!');
}
```

Thanks!