g4t / laravel-multithread
laravel 多线程模拟。
1.0.1
2022-05-12 06:33 UTC
This package is auto-updated.
Last update: 2024-09-13 18:21:10 UTC
README
📌 注意:此包目前仅在Linux上工作。
安装
在您的服务器上安装nodejs。
sudo apt-get install nodejs
使用以下命令使用composer安装此包
composer require g4t/laravel-multithread
使用方法
在仓库的examples文件夹中有示例
use g4t\Multithread\Run; public function index() { if(Run::check()) { $files = $this->query(); # This is an example of query Run::multithread($files); # pass query response to `multithread` function } else { $data = Run::request(); # this similar to work `Request $request` # The same data that comes from the query # here what we want to do in multithreaded $path = public_path()."/files//".$data['name']; shell_exec("wget {$data['url']} -O {$path}"); } } public function query() { $files = [ [ "id" => 1, "name" => "file1.zip", "url" => "https://speed.hetzner.de/100MB.bin" ], [ "id" => 2, "name" => "file2.zip", "url" => "https://speed.hetzner.de/100MB.bin" ], [ "id" => 3, "name" => "file3.zip", "url" => "https://speed.hetzner.de/100MB.bin" ] ]; return $files; }
许可证
laravel多线程模拟是免费软件,根据MIT许可证授权。
