Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Freek Lijten:
Separating concerns even better with events
Mar 09, 2015 @ 09:17:26

Freek Lijten has a new post to his site today today talking about a concept of good OOP design, separation of concerns, and how the use of events can help make it "even better". In it he converts some code from a decently structure state into something even driven, splitting out the work from the handling code.

At PHP Benelux 2015 I witnessed a talk by Matias Noback about events. It was a great talk so if you have chance to see it yourself somewhere, do so! In a very tiny nutshell he took us from what most would consider already decent code to better code. Lets start with "decent".

His "decent" code handles user management, executing certain business rules once the user is successfully registered. In the first version of is code, the User is passed into the "saveUser" function and several actions are performed (is the username in use? can they be saved?) including the sending of the email as requested once a user registers. This code is primarily procedural, all in one place and Freek updates it using events to make it a bit more well-contained. He extracts the piece sending the email and translates that into an event. This is then pushed into a set of handlers and executed allowing for greater flexibility if additional actions are needed in the future.

tagged: seperation concerns events tutorial introduction

Link: http://www.freeklijten.nl/home/2015/03/09/Separating-concerns-even-better-with-events

Mathias Noback:
Some questions about the command bus
Jan 12, 2015 @ 09:46:46

Mathias Noback has continued his series looking at the use of command busses in PHP applications. In this third part of his series, he answers some questions that have been asked by his own readers.

So far we've had three posts in this series about commands, events and their corresponding buses and handlers: a wave of command buses, responsibilities of the command bus, from commands to events. Now I'd like to take the time to answer some of the very interesting questions that by readers.

He answers questions about:

  • The difference between commands and events
  • Disadvantages of using a command bus
  • The command as constructor argument
  • How to return a value from the command bus
  • Could commands handle themselves?

Each question comes with a portion of the question from the original author, an explanation and some code where needed to illustrate his point.

tagged: commandbus question answer reader events disadvantages return handling

Link: http://php-and-symfony.matthiasnoback.nl/2015/01/some-questions-about-the-command-bus/

Matthias Noback:
From commands to events
Jan 09, 2015 @ 10:43:09

Matthias Noback is back with another post in a series looking at using a command bus to execute more complex code in somewhat of an isolation from the rest of the application. In this new post he moves on to some of the secondary tasks that happen inside the commands and how those relate to event handling.

In the previous posts we looked at commands and the command bus. Commands are simple objects which express a user's intention to change something. Internally, the command object is handed over to the command bus, which performs the change that has been requested. While it eventually delegates this task to a dedicated command handler, it also takes care of several other things, like wrapping the command execution in a database transaction and protecting the original order of commands.

He gets into some of these secondary tasks inside of the commands themselves - smaller actions that need to be done as a part of the execution of the command as a whole. He points out that it's tempting to do everything inside the command, but that it can lead to maintenance issues down the line. He suggests that the command shouldn't perform these tasks at all. They should be handled by an event system that uses event objects to pass off responsibility for performing actions to other objects (for example, handling the post-signup process once a user is created). He's done some research on some event dispatchers currently available but found them lacking in one way or another. Instead he opted to integrate one into his SimpleBus library (EventBus) to provide an integrated way of handling these secondary events. An example of it in use is also included.

tagged: commands events commandbus simplebus secondary task dispatch

Link: http://php-and-symfony.matthiasnoback.nl/2015/01/from-commands-to-events/

Michael Dowling:
Guzzle 5 and RingPHP
Oct 14, 2014 @ 10:52:25

Michael Dowling has a new post to his site today talking about the latest release for the Guzzle HTTP library and how it now works with RingPHP to make integration life easier. The RingPHP library, inspired by Clojure's Ring library, provides a low-level structure to work with HTTP clients and servers through a simple interface.

With RingPHP, Guzzle does not require cURL and can be used with any HTTP transport mechanism. I’d love to help anyone who is interested in creating RingPHP adapters to bind Guzzle to another library. For example, WyriHaximus on Github is working on binding Guzzle to ReactPHP. (In fact, Guzzle 4 did not require cURL, though it was much harder to use an alternate transport.)

He goes on to talk more about the changes in the Guzzle 5 release including more detail on the RingPHP integration, the use of promises/futures and iterable and callable streams. There's also several new events included in the release as well. He finishes out the post with an upgrade guide to help make the transition easier.

tagged: ringphp guzzle5 release http promise future psr7 streams events

Link: http://mtdowling.com/blog/2014/10/13/guzzle-5/

Zumba Fitness Engineering:
Using Application Events to Hook in Plugins
Aug 09, 2012 @ 09:23:37

In this recent post on the Zubma Fitness Engineering site, Chris Saylor looks at using events in your applications to hook in plugins to easily (and dynamically) enhance functionality.

In many instances, having a plugin system (even for closed-source applications) is a convenient and safe approach to adding functionality to a product. It minimizes risk by not having to modify the core of the source. In this article, I’ll be discussing how we implemented a plugin system for our cart software to allow for plugins.

Its implemented a bit like the Observer design pattern - you "register" the listening event which can then be activated by a "trigger" method with the event's name. These events are stored in a registry (static) so they can be accessed across the application.

tagged: events plugin trigger register tutorial observer

Link:

MaltBlue.com:
Why Zend Framework Plugins Save You Time
Jul 05, 2012 @ 11:44:41

On the MaltBlue.com blog today there's a new post talking about Zend Framework plugins and how they can help save you time in the long run, giving you more time and flexibility to create the applications you want.

During the recent development of the new PHP cloud development casts site, which has been developed with the Zend Framework, so much development time has been saved by using one of the simplest and arguably best features of the framework: Controller Plugins. So today I want to introduce you to them and walk you through a working plugin so you can see just how effective and efficient they can make your development workflow.

He starts with a look at the events that fire in the process of plugin execution (including "routeStartup" and "preDispatch") and as well as some common uses like inserting code at the end of a request automatically or redirecting a user if they're not logged in. Included in the post is a simple code example showing the setup of a simple plugin that redirects the user to the "/index/index" path if they're not already there.

tagged: zendframework plugin tutorial events

Link:

Rob Allen's Blog:
A list of ZF2 Events
Mar 16, 2012 @ 09:49:15

In a reference sort of post, Rob Allen has listed out the events that are provided in the Zend Framework 2 "Application" functionality.

Both the Module Manager and the MVC system use the Event Manger extensively in order to provide "hook points" for you to add your own code into the application flow. This is a list of the events triggered by each class during a standard request with the Skeleton Application.

It's broken up into the three main chunks - Module Manager, Bootstrap and Application - with any sub-requests and their sources (like "render", "dispatch" or "response"). You can find out more about ZF2's Event Manager in other posts like this one from Kevin Schroeder or this from Matthew Weier O'Phinney.

tagged: zendframework2 events eventmanager source

Link:

Smashing Magazine:
Upcoming Conferences and Events for Designers and Developers in 2011
Feb 15, 2011 @ 10:42:03

Smashing Magazine has posted their latest Upcoming Conferences list for the events happening in March through August of 2011.

We’re well into 2011, and many designers and developers around the world are planning their travels for the year, including the possibility of attending any Web design or development conferences. To help you out with your plans for the upcoming months, we’ve put together a list of conferences and events that you might want to consider. This particular post covers events taking place in about a six month timeframe that ends in late August and early September.

Their list includes PHP-related events such as the International PHP Conference and events surrounding many other technologies like Ruby, Photoshop, MySQL, Javascript and lots of other more business-minded sort of events. Check out their full list to see which ones you might want to attend.

tagged: events design developer conference list

Link:

Alexander Netkachev's Blog:
Practical PHP events: The Java way
Nov 01, 2006 @ 13:58:00

Continuing on with his look at events in PHP, Alexander Netkachev takes another look today at another type of approach to his handy feature - the "Java way".

In my previous article I summarized event system definitions and showed an example of PHP event model, which is built with the call_user_func() function. This acticle expands the subject by introducing an advanced PHP event model that is based on sender/eventObject/listener collaboration, which was popularized by the Java world.

He steps through some examples with ProtocolCommandSupport.java and ProtocolCommandListener.java functionality, showing how to take that functionality back over to PHP and implement it using the built-in features.

tagged: events java way practical tutorial events java way practical tutorial

Link:

Alexander Netkachev's Blog:
Practical PHP events: The Java way
Nov 01, 2006 @ 13:58:00

Continuing on with his look at events in PHP, Alexander Netkachev takes another look today at another type of approach to his handy feature - the "Java way".

In my previous article I summarized event system definitions and showed an example of PHP event model, which is built with the call_user_func() function. This acticle expands the subject by introducing an advanced PHP event model that is based on sender/eventObject/listener collaboration, which was popularized by the Java world.

He steps through some examples with ProtocolCommandSupport.java and ProtocolCommandListener.java functionality, showing how to take that functionality back over to PHP and implement it using the built-in features.

tagged: events java way practical tutorial events java way practical tutorial

Link: