tohidplus/paravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tohidplus/paravel

Composer 安装命令:

composer require tohidplus/paravel

包简介

A package to run anonymous functions in parallel

README 文档

README

GitHub issues GitHub stars Total Downloads Code Quality GitHub license

Parallel and Asynchronous functions in Laravel

A Laravel package to run anonymous functions in parallel or asynchronously without need to install any extension.

Installation

composer require tohidplus/paravel

Laravel

Publish the config file

php artisan vendor:publish --provider="Tohidplus\Paravel\ParavelServiceProvider"

Lumen

Copy the config file paravel.php from vendor/tohidplus/paravel to config directory and configure it in bootstrap/app.php

$app->configure('paravel');
//
$app->register(Tohidplus\Paravel\ParavelServiceProvider::class);

Configuration

return [
    'artisan_path' => env('PARAVEL_ARTISAN_PATH', base_path('artisan')),
];
  • Make sure the artisan path is correct.

Basic example

<?php
use Tohidplus\Paravel\Facades\Paravel;

$time = microtime(true);        

$results = Paravel::add('label_1',function (){
    sleep(5);
    return 'Hello there';
})->add('label_2',function (){
     sleep(5);
     return 'Hello again';
})->wait();

//Check the total execution time
dump(microtime(true)-$time); // 5.* Secs

Run functions in background

<?php

use Tohidplus\Paravel\Facades\Paravel;
   
Paravel::add('label_1',function (){
    return 'Hello there';
})->add('label_2',function (){
     return 'Hello again';
})->run();

Helper methods

<?php

use Tohidplus\Paravel\Facades\Paravel;

$results = Paravel::add('label_1',function (){
    return 'Hello there';
})->add('label_2',function (){
     return 'Hello again';
})->wait();

// Get the item by label
$results->get('label_1');
// Get result of item
$results->resultOf('label_1');
// Get error of item
$results->errorOf('label_1');
// Get status of item
$results->statusOf('label_1');

// Check if all processes were succeeded.
$results->succeeded();
// Check if any of the processes was failed.
$results->failed();

Notice: Paravel comes with 100 milliseconds overhead by default. So before starting to use this package make sure the total execution time of processes is over 100ms.

Contribution

Please feel free to open issues or have contribution.

统计信息

  • 总下载量: 159
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固