News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lukas Smith's Blog:
Lets talk about JSON in Symfony2
October 28, 2010 @ 12:13:43

Lukas Smith has a new post to his blog looking at some of his experiences with working with JSON in the upcoming version of the Symfony framework (Symfony2), specifically in using the DoctrineUserBundle and load views via JSON.

Unfortunately right now there are quite a few issues with taking a 3rd party Bundle which wasn't specifically build to be accessible via JSON. So in the end I build a MultiplexController that can JSON-ify any controller. The name derives from the fact that it also supports calling multiple routes at once and returning all the data from all these routes in one request. But being good OSS citizens here at Liip, we decided to use this opportunity to try and come up with a more sustainable solution. The goal would be to make it essentially possible to have a 3rd party controller return JSON without having to do anything on the controller level.

He talks about the "magic" that lets you define the output format you'd like and how it works on the backend with the templating system to use templates based on the requested file. He points out a few issues with the method - a form request problem and that there's no good way to call json_encode from inside a twig template (as well as redirecting after submission).

4 comments voice your opinion now!
json symfony2 issues opinion suggestion jsonencode


blog comments powered by Disqus

Similar Posts

Anna Filina's Blog: Podcast About Sexism in Tech: What I Learned

Watts Martin's Blog: PHP is not an acceptable COBOL

Pádraic Brady's Blog: PHP: Innocent Villagefolk or a Pillagin' Pirate?

Test.ical.ly Blog: PHP 5.3 and the Symfony2 UniversalClassLoader - Where to load?

php|architect\'s ART: JSON and PHP - More Than Web Services


Community Events

Don't see your event here?
Let us know!


api example podcast laravel5 series introduction php7 language laravel library unittest community voicesoftheelephpant extension release framework interview opinion install version

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework