getAttributes()['code']; $playlist = $this->getPlaylist($code, true); $playlist->fetchContent(); $playlist->parse(); $json = json_encode($playlist->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $response->getBody()->write($json); return $response ->withHeader('Content-Type', 'application/json') ->withHeader('Content-Length', strlen($json)); } }