Download the PHP package kukewang/hyperf_xxl_job without Composer

On this page you can find all versions of the php package kukewang/hyperf_xxl_job. 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 hyperf_xxl_job

[toc]

hyperf_xxl_job

此为 xxl-job 的 PHP 版本的任务执行器(Job Executor),特别适配于 Hyperf 框架,其余框架尚未验证适配性

此版本根据 hyperf/xxl-job-incubator 改造而来

优点

使用须知

  1. xxl-job 服务端版本需 >= 2.2.0
  2. 无法取消正在执行的任务

Bean 模式(类形式)

Bean 模式任务,支持基于类的开发方式,每个任务对应一个 PHP 类

优点:与 Hyperf 整合性好,易于管理
缺点:任务运行于单独的,协程任务代码不能存在阻塞 IO,每个 Job 需占用一个类文件,Job 逻辑简单但数量过多时过于累赘

Glue 脚本模式

该模式下,可支持任务以将源码方式维护在调度中心,支持通过 XXL-JOB 提供的 Web IDE 在线编写代码和在线更新,因此不需要指定固定的 JobHandler
脚本模式支持多种脚本语言编写 Job 代码,包括 PHP、Python、NodeJs、Shell、PowerShell,在 XXL-JOB 新建任务时选择对应的模式即可,例如 GLUE(PHP) 即代表 PHP 语言的脚本模式,所有脚本模式的任务会以一个独立的进程来运行,故在 PHP 下也可支持编写存在 IO 阻塞的代码

要使用 Glue 脚本模式 必须配置 Access Token 方可启用

优点:极度灵活,可以实现不重启新增和修改 Job 代码,支持多种脚本语言,独立进程
缺点:大批量任务时容易造成进程数过多,脚本代码由 XXL-JOB 远程编辑发放容易导致安全问题,Job 代码可对 Executor 所在服务器环境进行与启动 Hyperf 应用的权限相同的操作

Hyperf 中使用

安装 kukewang/hyperf_xxl_job

  1. composer地址,当前环境中需要有 git 环境,组件的依赖包需要使用 git 拉取

    composer require kukewang/hyperf_xxl_job

  2. 发布配置文件

    php bin/hyperf.php vendor:publish kukewang/hyperf_xxl_job

  3. 配置文件: config/autoload/xxl_job.php

  4. .env 文件

Hyperf 框架创建任务类

  1. 在 Hyperf 框架中创建任务类,并继承 use Hyperf\XxlJob\Handler\AbstractJobHandler
  2. 实现 execute 方法,业务逻辑在此方法中编写
  3. 添加注解 @XxlJob(jobHandler="testJobHandler",init="init",destroy="destroy")
    1. jobHandler 调度中心创建任务的 JobHandlerimage-20211208140702602
    2. init 执行 execute 方法前的初始化方法,方法名自定义
    3. destory 执行 execute 方法后执行的方法,方法名自定义

调度中心配置

  1. 创建执行器

    image-20211208142529463

    注册方式:自动注册

  2. 创建任务

    image-20211208142855343

    1. 执行器 根据需要添加
    2. 填写 cron 规则
    3. 运行模式选择 BEAN
    4. JobHandler 自定义
  3. 根据创建的 执行器 和 任务 填写 Hyperf 配置

    1. .env

    image-20211208143304563

    1. 任务类

      image-20211208143543278

引用

关于 XXL-JOB 更多的使用细节可参考 XXL-JOB 官方文档


All versions of hyperf_xxl_job with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
guzzlehttp/guzzle Version ^6.3|^7.0
hyperf/di Version ^2.2
hyperf/event Version ^2.2
hyperf/framework Version ^2.2
hyperf/http-server Version ^2.2
hyperf/logger Version ^2.2
jetbrains/phpstorm-attributes Version ^1.0
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 kukewang/hyperf_xxl_job contains the following files

Loading the files please wait ....