You need to set CURLOPT_RETURNTRANSFER, now curl_exec() will print out the result immediatly instead of returning it as a string in other words $output
will not be filled.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Also your cast to an array with json_decode with true is not necessary.