Download the PHP package hongxunpan/simple-event without Composer

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

simple-event

hongxunpan/simple-event 是面向 hongxunpan/simple-framework 的事件 Module。

它提供:

同步模式不依赖 Redis。只有选择 RedisStreamDriver 时才需要安装并启用 hongxunpan/simple-redis。

安装与启用

Composer 只负责安装包。event()、Provider 和生命周期适配只有在 Event Module 启用后才进入 应用运行时。

定义事件与监听器

Event

Event 表达已经发生的业务事实快照:

约束:

监听器

同步监听器:

异步监听器实现 ShouldQueue:

监听器的 handle() 必须:

分发与消费

同步配置

项目 config/events.php:

触发:

同步监听器按配置顺序执行。普通同步监听器异常会原样向上传播,并停止后续监听器。

best-effort

明确允许失败且不应污染调用链的监听器可以实现:

best-effort 异常会交给 ListenerFailureReporter,但不会阻断后续监听器。 项目可以通过 Provider 覆盖该契约。

Redis Streams

安装并启用 Redis Module:

config/redis.php 只保存连接配置:

config/events.php 保存 Event Driver 配置:

Redis host、认证、TLS、database 和 prefix 属于 Redis Module;stream、group、批次、 pending 回收和 failed stream 属于 Event Driver。两个配置边界不能混用。

RedisStreamDriver 不读取或编辑 module.enable,只校验 Redis 公开类型、容器绑定与所选 命名连接。通常由已启用的 Redis Module 提供这些运行时能力;项目若替换 Redis Provider, 也必须完整提供相同公开绑定。

Worker

单轮消费:

持续运行:

信号处理、命令退出码和 Supervisor/systemd 配置由项目负责。

Redis Streams 使用 at-least-once 语义:

Worker 执行上下文

EventExecutionContext 是容器单例,用于暴露当前正在处理的异步消息事实。监听器和项目级失败 Reporter 执行期间可以读取:

Worker 会在每条消息开始时建立上下文,并在 ACK、失败转存或异常结束后通过 finally 清空;上下文不能作为业务数据存储,也不能跨消息保留。

项目覆盖 TraceIdProvider 时可使用 FrameworkRequestTraceIdProvider:HTTP 发布 Event 时沿用 framework Request ID,Worker 内再次发布 Event 时沿用当前消息的 trace ID。

项目覆盖

项目 Provider 可以覆盖:

默认 Loader 只读取 config/events.php。若项目不希望使用 events 作为配置名称,应覆盖 EventConfigLoader,不要在包内增加旧键兼容或项目专用回退。

生命周期

Event Module 会把 framework 的:

转换为 Event Module 自己的生命周期事件。framework core 不引用 simple-event,也不会直接调用 event()。

验证

共享工作区使用:

当前开发线要求 PHP ^8.5。


All versions of simple-event with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-json Version *
hongxunpan/simple-framework Version ^0.3
symfony/property-access Version ^7.0
symfony/property-info Version ^7.0
symfony/serializer Version ^7.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 hongxunpan/simple-event contains the following files

Loading the files please wait ...