Download the PHP package wilson_yang/sendtask without Composer

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

async-task

simple task tools by swoole

客户端有两种实现方式:

  1. 使用 swoole client 实现
  2. 使用 stream_socket_client 实现

原理

通过Swoole 的TCP Server 接收客户端发过来的消息,消息都是经过序列化的,用 PHP_EOL 拼接,在 Server 工作进程中再进行拆分。 按照消息类型(目前只支持AbstractTask类和linux系统shell类命令)分别运行。 DB采用Mysql PDO 实现,配置了持久化。 Server中的DB资源都是在运行时进行注入的,运行时可以复用一个DB连接,减少了资源消耗。

用法

启动server

分别执行bin目录下对应的shell脚本即可,

配置文件

都放在config文件夹中,客户端和服务端可以分别部署在不同机器上,只需将swoole.php文件中的ip字段按照网络情况相应改写即可。

添加任务

在其他地方使用的时候只需要类似如下方式

方式一:执行某个外部命令(推荐方式) 建议在各种MVC框架下使用命令行形式去执行有关任务,可以避免再去重新学习适应当前这个框架中的逻辑。 执行的外部命令需要进行审核,目前未进行权限和用户的相关处理 (以免有些未经过审核的shell运行,危及系统安全,例如rm -rf /),

使用方式

方式二:在 task 文件夹中继承 AbstractTask 抽象任务。按照例子中去实现

不同项目中,如果使用这种方式,需要注意在server项目中注册client的加载路径,否则会出现命名空间找不到的问题。如下介绍了不同框架中使用该方式的方法:

在CI框架中使用的方法

安装

composer require wilson_yang/sendtask

配置

然后执行在本框架根目录下执行composer dump-autoload,然后重启server执行./bin.reload。 :sun: :dog:

在laravel框架下使用的方法

安装

composer require wilson_yang/sendtask dev-dev

发布

php artisan vendor:publish --provider="Wilson\Async\Provider\TaskServiceProvider"

启动服务器

php artisan swoole:task start|stop|reload|restart

编写任务

继承 Wilson\Async\Task\AbstractTask 抽象类即可,需要实现其中的 handle方法。

在fpm中执行一些exec类的需要高权限的操作

因为一般的fpm安全限制,我们一般无法使用 exec\shell_exec 之类的 PHP 内建函数。 如果我们使用异步客户端将命令发给以高权限运行的server去执行,那么就可以成功了。 例如我们希望通过网页上的某个按钮去发起服务器上的某shell脚本执行部署操作。

TODO

考虑异步任务失败情况,回收存储失败任务


All versions of sendtask with dependencies

PHP Build Version
Package Version
Requires catfan/medoo Version ^1.5
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 wilson_yang/sendtask contains the following files

Loading the files please wait ....