Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stratedge/lumen-pretty-json
A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default
https://github.com/stratedge/lumen-pretty-json
Last synced: 5 days ago
JSON representation
A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default
- Host: GitHub
- URL: https://github.com/stratedge/lumen-pretty-json
- Owner: stratedge
- Created: 2015-05-20T03:24:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-20T04:28:17.000Z (over 9 years ago)
- Last Synced: 2023-03-23T13:21:53.563Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lumen-pretty-json
A clean and simple way to have JSON output through Lumen's ResponseFactory class use JSON_PRETTY_PRINT by default. No requirement to pass a status and headers just to then set the JSON option for JSON_PRETTY_PRINT. Handy for APIs where all the returned content is JSON.
## Usage Examples
### Instantiating The ResponseFactory
```
json([
"id" => 10,
"first_name" => "Abraham",
"last_name" => "Lincoln"
]);
}```
### Injecting the ResponseFactory
```
json([
"id" => 10,
"first_name" => "Abraham",
"last_name" => "Lincoln"
]);
}
```## Output
In browsers like Chrome, using the combination of JSON_PRETTY_PRINT and the application/json content type, output will display in a more readable fashion, without any additional markup:```
{
"id": 10,
"first_name": "Abraham",
"last_name": "Lincoln"
}
```