laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.36k stars 10.97k forks source link

REQUEST: Out-of-the-box Response Formats for REST Controllers #2225

Closed abishekrsrikaanth closed 11 years ago

abishekrsrikaanth commented 11 years ago

I have been a great fan of Phil Strugeon's Rest Server bundle for CodeIgniter which provides great flexibility on the formats that it supports out of the box. It would be good to have something like this when working with REST Controllers on Laravel 4. I am sure there are a many who would find this very helpful.

FuelPHP's Rest Controllers has this out-of-the-box and the above plugin does wonders on CodeIgniter.

carbontwelve commented 11 years ago

I'm confused with exactly what features the bundle for CodeIgniter has, that Laravel4 doesn't? Could you explain some more?

abishekrsrikaanth commented 11 years ago

@carbontwelve, with a response, it supports the following output content types/formats.

xml - almost any programming language can read XML
json - useful for JavaScript and increasingly PHP apps.
csv - open with spreadsheet programs
html - a simple HTML table
php - Representation of PHP code that can be eval()'ed
serialize - Serialized data that can be unserialized in PHP

I don't see this existing on L4 with an exception for json using Response::json

with the other 2, all i require to do is $this->response($obj); and the client can use any of the above formats that they require.

carbontwelve commented 11 years ago

Oh, yes that makes complete sense now.

taylorotwell commented 11 years ago

Perfect thing for a package.