Download the PHP package lifetime/swoole-server without Composer

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

Swoole 服务器

swoole-server 对swoole的各类服务器进行一个简单的封装,让使用的时候更加方便。

已对以下服务器进行封装

配置类 \swoole\Config

\swoole\Config 包含swoole服务器的所有配置项,详情参考 配置

\swoole\Config 类有三种使用方法
第一种:

第二种:

第三种:

参数需要参考swoole官方文档,前两种方法采用下划线命名,第三种类属性需要采用小驼峰命名

常量参数类 \swoole\Options

\swoole\Options 包含了一些常用的swoole常量,比如:运行模式、Server类型、Task 进程与 Worker 进程之间通信的方式等。

事件类

所有的事件类都在 \swoole\event 命名空间下,每个服务器有相对应的事件类,开发时,可以继承事件类,重写对应的事件;然后在 Config 中设置 event_class 为事件类的名称,注意,必须包含完整的命名空间。

MQTT 的事件类中 为了不与 swoole 的 onConnect 事件冲突,MQTT业务的连接事件为 onMqttConnect

服务器类

所有的服务器类都在 \swoole\server 命名空间下
通过几行代码就可以启动一个服务器:

如果你想在启动之前做一些其他事情,可以这样操作

服务类的 getServer 方法会返回 swoole 的 Server 实例,可以进行其他的操作。

如果你不喜欢启动、停止时默认输出的消息的话,你也可以自定义消息。如:

getMasterPid 可以获取服务器管理进程的pid,注意:必须是和启动时相同的配置。
isRuning 可以获取指定服务器的运行状态。

文件监控

文件监控需要配置 Configfile_moniotrfile_list 选项;文件必须是绝对路径。

有几点要注意:

首先要注意新修改的代码必须要在 OnWorkerStart 事件中重新载入才会生效,比如某个类在 OnWorkerStart 之前就通过 composer 的 autoload 载入了就是不可以的。

其次 reload 还要配合这两个参数 max_wait_timereload_async,设置了这两个参数之后就能实现异步安全重启。

定时器服务

配置

任务类

任务类继承 \swoole\extend\abstcats 抽象类,需要完成 hanndle 方法

crontab 属性参照 Linux 的 Crontab 配置

注意:这里比 Linux 的 Crontab 多了一个秒

启动

除了 start 之外,还有 stopreloadrestart方法。


All versions of swoole-server with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-swoole Version >=4.5.8
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 lifetime/swoole-server contains the following files

Loading the files please wait ....