dimanche 25 février 2018

Creating multiple zip files with PHP

I have a problem in PHP / Laravel to create multiple zip files synchronously, I copy all commands that is generated and squeeze into the Shell, it executes normally, but when I step into the PHP run it only generates the first file = /.

Controller code.

foreach ($passwords as $p){
        if($i == 0){
            $command = 'zip -u -j -P '.$p.' '.$dir.'/'.$count.'.zip '.storage_path().'/app/'.$directory.'/'.$file1->getClientOriginalName();
            $commands->push($command);
        }else{
            $command = 'zip --quiet -j -P '.$p.' '.$dir.'/'.$count.'.zip '.storage_path().'/app/'.$directory.'/'.($count+1).'.zip';
            $commands->push($command);
        }
        $count--;
        $i++;
    }
    foreach ($commands as $p){
        echo $p.'<br/>';
    }
    foreach ($commands as $c){
        $process = new Process($c);
        $process->start();
        sleep(10);
        if($process->isTerminated()){
            sleep(1);
        }
        if ($errorOutput = $process->getErrorOutput()) {
            throw new RuntimeException('Process: ' . $errorOutput);
        }
    }

Data $commands

The script only generates the file 50.zip.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Fuq00Q
via IFTTT

Aucun commentaire:

Enregistrer un commentaire