News Feed
Sections




News Archive
feed this:

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

Matthias Noback:
Symfony2 Event subsystems
August 25, 2014 @ 10:07:09

In his latest post Mathias Noback takes a look at the Symfony2 event subsystems and the answer to a common problem he's had with it in the past: circular references.

Recently I realized that some of the problems I encountered in the past could have been easily solved by what I'm about to explain in this post. [...] The problem is: having a complicated graph of service definitions and their dependencies, which causes a ServiceCircularReferenceException, saying 'Circular reference detected for service "...", path: "... -> ... -> ...".' Somewhere in the path of services that form the circle you then find the event_dispatcher service.

He shows the wrong way to solve the problem first by injecting a service container into the listener and using services directly from there. In his "entirely different and much better way" he shows a solution that removes dependencies on the main event dispatcher. He shows how to use the event subsystems to avoid this link and gives a more concrete example for domain-related events (with both code and config).

0 comments voice your opinion now!
symfony2 event subsystem listener dispatcher domain

Link: http://php-and-symfony.matthiasnoback.nl/2014/08/symfony2-event-subsystems/

Aura Framework Blog:
A Peek At Aura v2 -- Aura.Dispatcher
November 05, 2013 @ 11:30:32

On the Aura framework blog there's a new post with a sneak peek at Aura.Dispatcher to handle the mapping between names and objects to handle the given request. The Aura framework provides high-quality, well-tested, standards-compliant, decoupled libraries that can be used in any codebase. This means you can use as much or as little of the project as you like.

In the lessons learned post, I talked about how Aura was born of the idea that we could extract independent decoupled packages from Solar, and how in doing so, we discovered that some of those extracted packages themsleves could be further split into independent pieces. Previously, I wrote about Aura.Sql-v2, Aura.Sql_Query, and Aura.Sql_Schema as extractions from a single Aura.Sql package. Today, I'm going to talk about Aura.Dispatcher as a combined extraction from three separate packages.

He starts off with a look at dispatchers in general, noting that they're usually used with request routing but the concept isn't limited to just that. He points out that CLI dispatching, as it turns out, is a lot like web request handling. The component makes routing both sides equally simple and could also be used as something like a micro-framework router. The post finishes up with this concept, talking about the evolution from micro- to full-stack framework structures and how the component could help.

0 comments voice your opinion now!
aura framework component spotlight dispatcher routing

Link: http://auraphp.com/blog/2013/11/04/aura-v2-dispatcher/

Gonzalo Ayuso:
Playing with event dispatcher and Silex. Sending logs to a remote server.
October 22, 2013 @ 09:44:57

Gonzalo Ayuso as a new post today showing the results of some of his testing with the event dispatcher and Silex to send logs to a remote server.

Today I continue playing with event dispatcher and Silex. Now I want to send a detailed log of our Kernel events to a remote server. We can do it something similar with Monolog, but I want to implement one working example hacking a little bit the event dispatcher. Basically we're going to create one Logger class (implementing PSR-3 of course).

He includes the sample code defining a "Logger" class that takes whatever message sent to it and pushes it into a given socket resource. He also creates a provider for the logger to implement it in the example and registers it with the event dispatcher. He hooks it into the request, get controller, terminate and exception events. On the other side he uses React to make a basic server to listen on port 4000 for the incoming log data.

0 comments voice your opinion now!
silex event dispatcher remote server log logger psr3

Link: http://gonzalo123.com/2013/10/21/playing-with-event-dispatcher-and-silex-sending-logs-to-a-remote-server/

Gonzalo Ayuso:
Using the event dispatcher in a Silex application
October 14, 2013 @ 13:03:26

Gonzalo Ayuso has a new post today showing you how to use the Symfony event dispatcher in a Silex-based application. His example involves a simple image processing example.

Symfony has one component called The Event Dispatcher. This component is one implementation of Mediator pattern and it's widely used in modern frameworks, such as Symfony. Silex, as a part of Symfony, also uses this component and we can easily use it in our projects.

His example creates a Silex endpoint that creates an image with a given string. He notes that handling it all at once and then unlinking at the end of the request is one way to handle it. The other is to use the event dispatcher to add an event lister (as a closure) to happen "on terminate" to unlink the path it's been given.

0 comments voice your opinion now!
event dispatcher symfony2 silex image generate

Link: http://gonzalo123.com/2013/10/14/using-the-event-dispatcher-in-a-silex-application/

Symfony-framework.com:
Symfony 1.1 - What's new?
November 28, 2007 @ 12:07:00

On the Symfony-framework.com website, there's a look at what's new in the latest Symfony build, version 1.1, as presented by Fabien Potencier at this year's International PHP Conference 2007.

In this article, I will briefly explain all the significant changes of Symfony 1.1 so that you will have fewer doubts deciding between: rewrite part of your old code, simply update your application or use the new Symfony 1.1 only in new developments.

There's three things he mentions - the new task framework to help organize code development, the reorganization of the event dispatcher and its dependencies, and the new Form, Widget and Validator framework.

0 comments voice your opinion now!
symfony framework presentation task event dispatcher form widget validator symfony framework presentation task event dispatcher form widget validator


Felix Geisendörfer's Blog:
Learning from the CakePHP source code - Part 2
September 29, 2006 @ 08:29:00

In his latest blog entry on the ThinkingPHP Blog, Felix Geisendörfer continues on with the series started here and shows that there's more to learn from the CakePHP source code.

In the previous post I was showing how to use the Dispatcher::dispatch() function. Now what's more interesting, is what it actually does and in what order.

He lists out the order of the process the Dispatcher follows:

  • Build the $params array
  • Find the base url
  • Load/Include the requested Controller
  • Possible Plugin Logic
  • Executing the Admin Route
  • Render a possible missingController error
  • Action exists? Action private?
  • Set Controller variables
  • Load Components & Models
  • Render possible missingAction/privateActione errors
  • Invoke the controller
It seems like a long way to go to just get the request to the right Controller, but it all happens in the blink of an eye when the page request is made.

If you've enjoyed the look at the Dispatcher, let Felix know - especially if you'd like to see other parts covered.

0 comments voice your opinion now!
cakephp framework source part2 dispatcher process cakephp framework source part2 dispatcher process


Peter Goodman's Blog:
Observers and Dispatchers
August 25, 2006 @ 08:30:37

As pointed out by Cal Evans on the Zend Developer Zone, there's a new look at Observers and Dispatchers over on Peter Goodman's blog.

Maybe you've used a framework that uses Observers and Dispatchers, or you've heard of them but don't know how they work. Well, I'm going to explain them and tell you why they're so useful.

He starts with a table defining the parts of this dynamic duo before jumping into the code examples and explainations. His first example is just a basic use of the pattern, while the second involves using a MySQL table for the notification events.

0 comments voice your opinion now!
pattern observer dispatcher mysql tutorial simple database pattern observer dispatcher mysql tutorial simple database


Felix Geisendörfer's Blog:
The ultimate CakePHP bootstrap technique
August 15, 2006 @ 07:19:54

In his latest blog post today, Felix Geisendörfer shares his "ultimate bootstrap technique" for CakePHP without having to render a page.

Ok, I shouldn't use such a buzz-headline, but I was very happy today, when I discovered a new way to bootsrap CakePHP wihout having to render a page. This is especially useful when you try to embed CakePHP in existing php apps (drupal, wordpress, ..., ?), or when you try to write unit tests for highly coupled classes such as Controllers or Models.

Basically, the technique involves tricking the Dispatcher into not rendering based on the $_GET values by making it think that it's being asked for the favicon.ico file.

0 comments voice your opinion now!
bootstrap cakephp technique favicon dispatcher bootstrap cakephp technique favicon dispatcher



Community Events





Don't see your event here?
Let us know!


series voicesoftheelephpant podcast conference deployment list tips bugfix code framework threedevsandamaybe api symfony interview community zendserver introduction language release laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework