Skip to content

A demo of serializing promises & resolving them in a separate (later) PHP thread.

Notifications You must be signed in to change notification settings

brentkelly/serialized-promise-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serialized Promises demo

This is a quick demo / proof of concept combining promises (React/Promise) with serializing (using Opis/Closure) - allowing us to create promises that resolve in a later PHP thread.

To make this work correctly, after composer install you need to maunually apply reactphp/promise#179 to vendor/react/promise/src/Promise.php.

Basic premise is a greeter class. When someone arrives we greet them, assign them an id & create a promise can be resolved when they leave - farewelling them by name.

For this to work the promise must not only successfully serialise its resolve closure, it must also retain/restore the $this instance being called within the then callback when the promise is resolved. If this fails it will not know the name to farewell.

Usage

  1. Ensure guests is writable.
  2. Run index.php. This will create a promise & give you instructions on resolving the promise.
  3. Run the command provided in step 2 - something like php resolve.php <id>

About

A demo of serializing promises & resolving them in a separate (later) PHP thread.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages