sabre/event 3 released

We just released sabre/event 3. This is a new major version, and comes with a number of new features and also BC breaking changes.


PHP version

This package now requires PHP 5.5. The 2.0 version of this package will continue to be maintained though if you need PHP 5.4 support.

Changes to Promises

We've overhauled the promise significantly to closely match the standard Ecmascript promise as close as possible.

To do this, we added the following functions:


These are now straight up functions, and not static methods on the Promise object.

The following methods were added:


Wait makes a lot of sense for PHP so it was added as a core feature.

The following methods were deprecated:


Both will still work but will be removed in version 4.0.

error was renamed to otherwise. In javascript this function is actually called catch, but we can't use that name in PHP because it's a reserved keyword. Other projects such as ReactPHP and Guzzle have settled on the name otherwise, so we're following their example.

Another change is that promise now uses the Event Loop to trigger events. This means that events are now predictably asynchronously triggered, whereas before events might have triggered synchronously.

What generally means is that you might need to explicitly call the wait() function on your promise to wait for it to resolve. Or you can call:


See the Promise documentation for more information.


We've added support for coroutines using PHP 5.5 generators. For a great example check out the documentation.

Event loop

We added an implementation of an Event Loop, also sometimes known as the reactor pattern. This new system behaves similar to Javascript or ReactPHP's loop. The event loop can handle 'timed events' a.k.a. setTimeout() and setInterval() and support for events on IO streams strictly using stream_select() as the underlying engine. See the Loop documentation for more information.


A full changelog can be found on Github

Tags: event, release, loop, promise, async, coroutine