webDEVILopers Blog
Domain-Driven Design and CQRS with PHP, Symfony and Doctrine.
Facebook Twitter GitHub
Menu Close
  • Home
  • About

XML

How to render XML response in Zend Framework 2

Posted on July 8, 2014 by Web Deviloper

Zend Framework 2 offers different Rendering and Response Strategies.

Unfortunately there is no out-of-the-box Strategy for XML.

Solely RSS Feeds are supported:

  • https://github.com/zendframework/zf2/blob/master/library/Zend/View/Strategy/FeedStrategy.php
  • http://samsonasik.wordpress.com/2012/09/18/zend-framework-2-viewfeedstrategy-generating-feeds/

Well, there is a Module by Alessandro Pietrobelli:

  • http://www.alessandropietrobelli.com/2012/11/29/ap_xmlstrategy-1-0-0-a-zend-framework-2-xml-strategy-module/
  • https://github.com/alessandropietrobelli/AP_XmlStrategy

If you want to render raw XML you can use these simple lines in your controller:

 

If you need to create complex XML files you can use the PHP XMLWriter which is included in ZF2:

 

Backlinks:

  • http://stackoverflow.com/questions/22431309/what-is-the-proper-way-to-return-xml-response-in-zend-framework-2-app
  • https://gist.github.com/webdevilopers/0311935df9ea7f0676d4
RSS, XML, Zend Framework 2, Zend Http, Zend View, ZF2 Modules RSS, XML, XMLWriter

Categories

  • Authorization (1)
  • Bundles (2)
  • Databases (1)
  • Doctrine2 (9)
  • Doctrine2 (5)
  • Domain-driven Design (2)
  • FOSUserBundle (2)
  • jqGrid (1)
  • KnpSnappyBundle (1)
  • MySQL (3)
  • ODM (1)
  • ORM (3)
  • ORM (4)
  • PHP (4)
  • Rbac (1)
  • RSS (1)
  • Sonata Project (9)
  • SonataAdminBundle (7)
  • SonataDoctrineORMAdminBundle (3)
  • SonataMediaBundle (1)
  • SonataUserBundle (4)
  • Symfony2 (10)
  • Twig (4)
  • Uncategorized (1)
  • wkhtmltopdf (1)
  • XML (1)
  • YAML (1)
  • YAML (1)
  • Zend Acl (1)
  • Zend Framework 2 (4)
  • Zend Http (1)
  • Zend Navigation (2)
  • Zend View (1)
  • ZF2 Modules (2)
  • ZfcRbac (1)

Recent Posts

  • Domain-Driven Design Repositories with Doctrine ORM and ODM in Symfony
  • PHP Symfony Doctrine Domain-driven Design
  • Environment-driven CDN host for SonataMediaBundle images in wkhtmltopdf generated with Symfony KnpSnappyBundle and TWIG

RSS Scoopt.it! topics

Our featured posts on Facebook

GitHub Activity

@webdevilopers
webdevilopers commented on issue Haehnchen/idea-php-symfony2-plugin#1158 Apr 3, 2018
@webdevilopers webdevilopers commented Apr 3, 2018

There is a "Browse repositories" Button @tzfrs .

@webdevilopers
webdevilopers commented on pull request symfony/recipes#179 Mar 13, 2018
@webdevilopers webdevilopers commented Mar 13, 2018

I can confirm the issue mentioned by @adamelso . We moved our App namespace to src/App. It looks like the annotations.yaml was added after we requi…

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

Now i finally recognized that onky the .conf file was created. log, pid and .sock were missing. That will cause the exception. What I cannot tell i…

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

; supervisor config file [unix_http_server] file=/var/www/vhosts/***/htdocs/releases/20180310101225/app/../supervisor/sps_intranet/supervisord.sock…

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

My provider just told me that the actual ".." could be causing the message. It does not seem to be allowed when setting the path for supervisor. I …

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

At the bottom line it looks like the error occurs if the configured directories are none-permanent. While a deployment with Capistrano a new folder…

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

Similar error messages here: spatie/laravel-backup#92 spatie/laravel-backup#285

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

Finally after using dev-master I get some logs in Symfony: [2018-03-10 10:18:27] app.DEBUG: Executing: supervisorctl --configuration=/var/www/vhost…

@webdevilopers
webdevilopers commented on issue Phobetor/rabbitmq-supervisor-bundle#36 Mar 10, 2018
@webdevilopers webdevilopers commented Mar 10, 2018

Just recognized we were running the following version: "phobetor/rabbitmq-supervisor-bundle": "2.0.0", It thought that release https://github.com/…

@webdevilopers
webdevilopers opened an issue in Phobetor/rabbitmq-supervisor-bundle Mar 10, 2018
No exception / error logged though starting fails #36

We use capistrano for deployment. It seems to have some problems with symlinks or similar. But we could break it down to the main problem. When we …

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© 2018 webDEVILopers Blog. All rights reserved.
Hiero by aThemes
0 Flares Twitter 0 Facebook 0 LinkedIn 0 0 Flares ×