So i want to run this script that will create around 1.5k files at once. But Not having so much success and the reason is it is only creating 5-10 files.
The reason being is because the script doesn't run long enough for it to create every file. Since im guessing file generation is async.
How can I do such a thing.
My code is the following.
try {
$this->tmp_file_name = 'article' . md5(time());
//-- open file
$file = fopen($this->tmp_file_name, 'w');
if (!$file) {
throw new \ErrorException('Cannot create ' . $this->tmp_file_name . ' file!');
}
//-- write file
$fwrite_result = fwrite($file, json_encode($data));
if (!$fwrite_result) {
throw new \ErrorException('Cannot create ' . $this->tmp_file_name . ' file!');
}
fclose($file);
return true;
} catch (\Exception $ex) {
return false;
}
Now this method is called over 1.5k times.