hasen's tech life

Twitter: @hasen

PHPでJSON形式の出力を見やすくする.

# PHPJSON形式の出力を見やすくする.
# Laravel v5.1.24で試してます.

# 通常
$ vi test.php
++ Log::info(json_encode(Input::all()));

$ tail -f storage/logs/laravel.log
> [2015-12-01 10:00:28] local.INFO: {"email":"test@hoge.com","password":"test_password","_token":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}

# 加工
$ vi test.php
++ Log::info(json_encode(Input::all(), JSON_PRETTY_PRINT));

$ tail -f storage/logs/laravel.log
> [2015-12-01 10:00:28] local.INFO: {
>   "email": "test@hoge.com",
>   "password": "test_password",
>   "_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
> }