Download the PHP package jeruier/swozr-taskr without Composer

On this page you can find all versions of the php package jeruier/swozr-taskr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swozr-taskr

swozr-taskr

php任务服务组件

Php Version Swoole Version

简介

在一些业务场景需要用户异步任务或秒级的定时耗时任务,在一些非swoole的php框架中未支持,在因需要共用一些业务框架逻辑或 不想再维护另一个单独部署的swoole框架的场景下,该任务服务组件可以解决这类问题。

功能特色

Install

Taskr Server Actions

配置服务

配置参数皆为可选,设有默认值

在可以配置应用组件的框架下配置taskr组件,你可以看到taskr数组里面包含了taskr的基本信息

例如Yii框架可以使用 Yii:$app->task->start(); 来启动服务

类配置参数启动

使用(new \Swozr\Taskr\Server\TaskrEngine($config))->start() 来启动服务

可配置项:

以下配置项皆为可选配置(非必须)

  • host 服务地址,默认值 0.0.0.0
  • port 端口,默认值 9501
  • MQProcessMum 配置rabbmitMq任务运行处理进程数,默认值1(在配置了rabbmitMqs时生效,且设置值需要小于setting的task_worker_num,配置的这几个任务经常将全权处理rabbmitMq任务,配置的task_worker_num减MQProcessMum的多余任务才会执行其他类型的任务)
  • type 指定Socket的类型,支持TCP、UDP、TCP6、UDP6、UnixSocket Stream/Dgram 等 Swoole Server 构造函数 第四个参数
  • pidName 启动后进程的名称,默认值swozr-taskr
  • pidFile pid存放路径,默认值/tmp/swozr.pid
  • logFile 指定swoole错误日志文件。在swoole运行期发生的异常信息会记录到这个文件中。默认会打印到屏幕,默认值/tmp/swoole.log
  • debug 是否开启debug,默认值true
  • on 配置监听的事件
  • setting 参考 Swoole Server 配置选项
  • listener 注册事件、设置对应事件的处理监听,事件触发组件调用,在任务里面使用
  • exceptionHandler 自定义异常处理类
  • crontabs 需要处理的定时任务集
  • rabbmitMqs 配置rabbmitMq任务

listener配置

listener为键为事件名称值为事件处理或事件处理数组

事件名称
  • Swoole事件:Swoole 文档中的每个事件,在 Swoft 里面均可监听,并且可以存在多个监听器。(完整事件列表请参阅 SwooleEvent.php 文件)
  • Swoft事件:基于 Swoole 的回调处理扩展了一些可用 Server 事件,提供更加精细的操作空间(完整事件列表请参阅 ServerEvent.php 文件)
    事件处理定义

    Event $event 事件

  • 闭包方式

exceptionHandler配置

exceptionHandler配置为键为指定异常值为异常处理类的数组

指定异常

可定义的异常

异常处理类

需要实现ExceptionHandlerInterface接口

配置自定义异常处理类

crontabs配置

项目有定时业务需求的时候定义crontabs数组,crontabs数组为键为任务格式值为继承BaseTask的类,必须定义静态变量$cron( Crontab 表达式,支持到秒) Cron格式说明

示例:

配置定时任务

配置rabbmitMqs任务

需要装php扩展:amqp

配置项

* 为必须配置项,可以配置多项(以多维数组的形式)

配置一项rabbmit任务

配置多项rabbmit任务

声明任务

定义一个任务类(必须继承BaseTask 且实现TaskConsume接口,除定时任务和rabbmitMq任务的其他任务还要实现 TaskNotice接口)

当配置为定时任务时需要继承静态属性进行配置$cron

可调用的类方法

可实现的方法

需要实现的TaskNotice接口

需要实现的实现TaskConsume接口

任务投递

TaskTest为声明的任务类,默认投递地址0.0.0.0,端口9501

TaskTest::publish(array $data, ...$varParams)

Taskr Client 发布任务的客户端

配置客户端

testing

Yii2框架使用示例

其他php框架使用方法类似

使用Taskr服务

应用组件的方式配置

之后你就可以通过语句 Yii::$app->taskr 来使用taskr服务了。

创建的控制台命令

运行该命令


All versions of swozr-taskr with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jeruier/swozr-taskr contains the following files

Loading the files please wait ....