Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

annecastrillon's avatar

Laravel API and XML - Best Practices?

So what are the best practices for building an API in Laravel that outputs xml? Currently I have a blade "view" that takes an array of data and outputs xml based on that array. However, when writing unit tests I've ran into trouble using this, in that the view helper and View::make method do not work at all within phpunit and generate invalid php.

We currently have to support XML for backwards compatibility with older clients, otherwise I would definitely just go with JSON. There aren't many articles on what the best practices for outputting xml in Laravel out there so I figured I'd ask here.

0 likes
0 replies

Please or to participate in this conversation.