hit, instance begins. Page hit, instance begins. – Initialize Initialize – Configure Configure – Setup Setup – Ready Ready • Input (handle GET, POST, decide what to do) Input (handle GET, POST, decide what to do) • Main (do what was decided) Main (do what was decided) • Output (toss it out to the browser, themed) Output (toss it out to the browser, themed) – Shutdown Shutdown
Synchronous Loosely Synchronous – Basis of a solid Basis of a solid plug-in system. plug-in system. • Asynchronous Asynchronous – Basis of a queue Basis of a queue service. service.
a Plug In System With Events and Things. With Events and Things. • Announce you are about to do something before you do it. Announce you are about to do something before you do it. – Allows a plugin to watch for this and do something else instead. Allows a plugin to watch for this and do something else instead. • Announce you just set a new value after you set it. Announce you just set a new value after you set it. – Allows a plugin to watch for this to either filter or completely Allows a plugin to watch for this to either filter or completely change a value. change a value. • Announce whenever an application milestone has been reached. Announce whenever an application milestone has been reached. – Allows a plugin to prepare functionality for later stages, or Allows a plugin to prepare functionality for later stages, or modify the output of what just happened. modify the output of what just happened. • Announce whenever an error occurs. Announce whenever an error occurs. – Allows a plugin to perhaps attempt a recovery, or log the error, Allows a plugin to perhaps attempt a recovery, or log the error, or explode in a more grandiose way. or explode in a more grandiose way.
$user = User::Get(42) Cache Library user-get user-42 I see what she did there. Here take my user-42. Log Library I heard you had a cache hit. I am gonna make a note of that in the debugging log. cache-get-hit user-42
• Intercepting Behaviour Intercepting Behaviour – Modifying / Filtering Modifying / Filtering – Blocking Blocking • Adding Behaviour Adding Behaviour – Drag and Drop Features Drag and Drop Features • Events can happen ANYWHERE. Events can happen ANYWHERE.
not prevent other Processing of an event does not prevent other events from being handled at the same time. events from being handled at the same time. – NodeJS NodeJS – Twisted (Python) Twisted (Python) – AJAX (jQuery makes it easy) AJAX (jQuery makes it easy) – GTK/Glib (and probably other GUI toolkits) GTK/Glib (and probably other GUI toolkits) – But, PHP? But, PHP?
A stand alone service that has one job: keep a A stand alone service that has one job: keep a list of things that need to get done and tell list of things that need to get done and tell clients the next thing to do when they say they clients the next thing to do when they say they are done with whatever they just did. are done with whatever they just did. • Live Communications... Live Communications... – Chat, Game Data, Task Status Updates... Chat, Game Data, Task Status Updates... – I could have written an IRC server demo but I could have written an IRC server demo but that would have been so 1988. that would have been so 1988.
quick jist. • Start the service. Start the service. • Begin listening for clients. Begin listening for clients. – Client connected? Assign functions to handle when Client connected? Assign functions to handle when the new connection sends data. the new connection sends data. • Supports multiple back ends: Supports multiple back ends: – PHP Streams (stream_select). Just works. Not the PHP Streams (stream_select). Just works. Not the fastest, but still faster than you. fastest, but still faster than you. – LibEvent (PECL wrapper of the C lib) LibEvent (PECL wrapper of the C lib) – LibEV (PECL wrapper of the C lib) LibEV (PECL wrapper of the C lib)
Promise Based Quick Client Promise Based Quick Client • React\Http\Server React\Http\Server – Similar to the Socket Server, but with extra events for Similar to the Socket Server, but with extra events for serving HTTP requests easier. REST server? serving HTTP requests easier. REST server? • React\HttpClient\Client React\HttpClient\Client – Event based HTTP client. REST client? Event based HTTP client. REST client? – Still has some important development TODO’s before Still has some important development TODO’s before being complete. being complete.