Laravel Livewire 中的 Exec 命令

问题描述

嗨,我在工匠命令中有以下代码

exec('rclone copy gdrive: --drive-root-folder-id '.$folderID.' storage/app/tmp/');
    //sleep(10);
    $platforms=array('Android','iOS','Linux','Windowsstore');
    foreach ($platforms as $platform ) {
        $existPlatform = Storage::exists('tmp/'.$platform);
        if($existPlatform){
            $isExists = Storage::exists('tmp/'.$platform.'/'.$uuid.'.zip');

            if ($isExists){
                
                $zip_file = 'storage/app/tmp/'.$platform.'/'.$uuid.'.zip';
                $zip = new ZipArchive ();
    
                if ($zip->open ($zip_file) === true) {
                    $zip->extractTo (storage_path ('app/tmp/'.$platform.'/'.$uuid.'/'));
                    }
                    $zip->close();
            
            }
            $files = File::allFiles('storage/app/tmp/'.$platform.'/'.$uuid.'');
            foreach($files as $file){
                if($bundLeversion!=1){
                    Storage::disk('s3-pruebas')->put(''.$platform.'/'.$bundLeversion.'/'.$uuid.'/'.$file->getFilename(),file_get_contents($file));
    
                }else{
                    Storage::disk('s3-pruebas')->put(''.$platform.'/'.$uuid.'/'.$file->getFilename(),file_get_contents($file));
    
                }
                
                
            }
        }
    }

代码所做的基本上是将本地文件夹与 rclone 同步到谷歌驱动器上。 如果我将该代码作为 laravel 命令运行,它可以完美运行。等待文件夹同步并继续。 另一方面,如果我创建一个 Laravel Livewire 组件,它不会通过复制相同的代码甚至调用 Artisan 函数来执行命令来工作。 使用 livewire 它只会为我创建 tmp 文件夹。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)