Download the PHP package tianhe1986/fatevent without Composer

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

Fatevent

Fatevent是一个轻量级的PHP事件库,使用非常容易。

安装

首先确保PHP版本在7.0以上。

推荐通过Composer进行安装

Composer的安装请参考官方配置。

安装好Composer后,在你的项目中创建一个 composer.json 文件:

然后在项目文件夹下执行:

之后添加autoloader:

使用

事件的处理示例如下,首先,需要监听某个事件,附加处理函数:

以上代码监听了test.test事件。接下来,在需要的地方触发对应的事件:

此时,之前附加的处理函数便会执行。在接下来的几个小节中,会详细的介绍使用的场景及函数。

增加监听

$name为事件名。

$handler为处理函数,函数定义如下:

$eventData为触发事件时附带的数据,$defaultData为监听时附带的数据。

$data为监听时附带的数据。

一个事件可以被多次监听,触发时多个处理函数会按监听的顺序依次调用。示例如下:

以上代码执行将输出

增加一次性监听

参数与on一样,只是此处理函数在一次之后会被移除,下次再触发同一事件时不会再被调用。示例如下:

以上代码将输出

事件停止处理

有时候,你希望停止事件被继续处理,你可以通过从处理函数中返回 false 来实现。如下所示:

以上代码将输出

注意,如果某个一次性处理函数还未被调用,事件就已经停止了,则此处理函数不会被移除。只有被调用过的一次性处理函数才会被移除。

取消监听

可以取消某个处理函数,使用示例如下:

注意,匿名函数无法被取消,如果需要取消,请使用某个变量储存它。

如果$handler为 null,则该事件上所有的处理函数都会被取消。

触发事件

会触发某项事件,其中$data为触发事件时附加的数据:

以上代码将输出


All versions of fatevent with dependencies

PHP Build Version
Package Version
Requires php 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 tianhe1986/fatevent contains the following files

Loading the files please wait ....