Yes, fwrite
function is limited to length, and for a large files you may split the file to a smaller pieces like the following:
$file = fopen("file.json", "w");
$pieces = str_split($content, 1024 * 4);
foreach ($pieces as $piece) {
fwrite($file, $piece, strlen($piece));
}
fclose($file);