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

Qafoo Blog:
Utilize Dynamic Dispatch
October 16, 2014 @ 11:52:18

On the Qafoo blog today Tobias Schlitt talks about dynamic dispatch, what he calls a "fundamental concept of OOP" to help provide clean, clear interfaces in the code.

I want to use this blog post to illustrate the concept of dynamic dispatch which I use a lot recently to motivate creating clean OO structures in my trainings. In my experience, this helps people to understand why we want to write code in this way. After that I will show why traits are bad in this direction.

He explains the concept of "dynamic dispatch" by starting from the beginning...with procedural PHP code. He looks at the usual flow of this kind of application that call shared functions in a "top down" fashion. He looks at what would happen if new logging needs were introduced (use a new method? patch the current one?) and the dependencies that can be introduced because of it. With this in mind, he continues and talks about how the "dynamic dispatch" happens during the code execution, splitting the log request based on the information it's given instead of different implementations for each. He points out that using a trait doesn't allow for this abstraction and instead embeds the code into the class itself, re-introducing the original problem.

0 comments voice your opinion now!
dynamic dispatch oop concept example logger trait compare

Link: http://qafoo.com/blog/072_utilize_dynamic_dispatch.html

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/

PHPMaster.com:
Implementing PSR-3 with log4php
January 15, 2013 @ 12:53:17

With the PSR-3 logging interface recently accepted by the PHP-FIG, Jamie Munro has written up a post for PHPMaster.com that shows how to implement the interface with log4php, the Apache logging tool.

With the recent passage of PSR-3, a standard for a common interface for logging libraries, it seems appropriate to discuss the implementation with my favorite logging library. log4php is an open source Apache project that is a very versatile logging framework. Through log4php's configuration files, logging has a variety of output locations, so it's possible to send specific log levels to different output locations.

He includes the Composer requirements for the interface and shares the code for a wrapper class that implements the Logger interface and defines methods for each of the logging levels (alert, notice, debug, etc). Also in the post is an example XML configuration for log4php and how to load it into your class instance.

0 comments voice your opinion now!
implement psr3 logger interface log4php apache tutorial


Community News:
PSR-3 Accepted - Logger Interface
January 15, 2013 @ 10:55:01

The PHP-FIG (Framework Interoperability Group) has recently accepted the PSR-3 definition for a standardized Logger interface structure that can be used for interoperability between frameworks (and other tools).

The main goal is to allow libraries to receive a PsrLogLoggerInterface object and write logs to it in a simple and universal way. Frameworks and CMSs that have custom needs MAY extend the interface for their own purpose, but SHOULD remain compatible with this document. This ensures that the third-party libraries an application uses can write to the centralized application logs.

The implementation of this structure into your application makes it easier should you decide to swap out logging tools or want to create your own that can be used across several different frameworks. This is the third PSR to be accepted by the group, following PSR-1 and PSR-2 more related to coding standards.

0 comments voice your opinion now!
logger interface psr3 phpfig interoperability framework logging


Stuart Herbert:
Personal Thoughts On The PSR-3 Log Proposal
December 31, 2012 @ 10:46:13

In his latest post, Stuart Herbert has shared some thoughts about the recently proposed PSR-3 proposal for a unified logging interface for PHP projects.

PSR-3 is a proposed standard (voting has finished, it should appear as an accepted standard when the PSR folks recover from too much Christmas turkey) describing a common logging interface for PHP frameworks. It's based on a small subsection of RFC 5424, which describes the Syslog standard, which is a very sensible choice. Sysadmins think in terms of Syslog levels, and they utterly hate dealing with loggers that don't map cleanly onto Syslog.

He briefly introduces the PSR and the format of the logger with some of the main methods it should implement and what they do. He talk gets into some of his critiques about the proposal, namely the method naming, the exception handling parameter and the proposed LogLevel constants.

0 comments voice your opinion now!
psr3 proposal phpfig logger interface thoughts opinion


ThinkPHP Blog:
MySQLnd Plugins Writing a MySQL Query Logger in PHP
August 18, 2010 @ 11:10:15

On the ThinkPHP blog there's a recent post looking at writing a query logger in PHP as a mysqlnd plugin using the mysqlnd_uh extension.

A new approach to implementing a query logger and potentially more complex features such as monitoring or read/write-splitting is the MySQLnd Userland Handler Extension (mysqlnd_uh, pecl website). The extension lets you register a PHP class as a proxy for every MySQLnd connection. Every call to a function to MySQLnd (usually indirect through mysqli, mysql, pdo_mysql) is passed to the PHP class, which then calls the original MySQLnd function.

They give a simple example to start - a logging function and how to configure it - followed by a more real-world scenario of logging inside of a project plugin.

0 comments voice your opinion now!
mysqlnd query logger plugin extension


phpRiot:
Zend Framework 101 Zend_Log
April 13, 2009 @ 08:46:13

Next up in the phpRiot "Zend Framework 101" series is this new look at the logging component of the Zend Framework - Zend_Log.

This article shows you how to use Zend_Log, the logging component of the Zend Framework. It allows you to record messages from your application however you please. In this article I will show you how to record messages to a log file. Additionally, if you use the Firebug and FirePHP plug-ins for Firefox, Zend_Log can be extremely useful for application development and debugging. I will also show you how to achieve this.

They walk you through the creation of a simple logger and putting it to use by recording just the events you want (via error levels). There's also an extra section on integrating it with the Firebug/FirePHP extensions for Firefox and push your messages directly to the browser.

0 comments voice your opinion now!
zendframework zendlog tutorial introduction logger firebug firephp writer


Raphael Stolt's Blog:
Turning a Zend_Log log file into a RSS feed
June 26, 2007 @ 08:33:00

In a new post to his blog today, Raphael Stolt shows how to take the output from the Zend_Log component of the Zend Framework and, with a bit of custom coding, make it output an RSS feed.

Whilst touring the web I found an interesting project for turning Apache Web Server log files into RSS feeds. This approach can be adjusted to monitor the maintenance needs of a web application deployed on an assumed productive system. Therefor a XML capable Zend_Log instance will be set up and the resulting log file will be transformed into a RSS feed via a custom Action Helper wrapping a XSLT transfomation.

He sets up the XML logger first, using the Zend_Log, Zend_Log_Writer_Stream and Zend_Log_Formatter_Xml to create the XML output from the logging. Then, with the help of the custom helper - Recordshelf_Controller_Action_Helper_Xslt - he reformats the XML output into an RSS feed ready for public consumption. (There's even a screenshot of what it might look like in a feed reader).

0 comments voice your opinion now!
zendlog rss feed xml logger actionhelper xslt zendlog rss feed xml logger actionhelper xslt


Northclick Blog:
Getting the PHP fatal errors
May 15, 2007 @ 07:49:00

From the Nothclick dev blog, there's this new post from Soenke Ruempler that talks about working with error messages in PHP, specifically with fatal errors.

One big issue of the PHP error handling is that there's no built-in way to catch fatal errors with an user-defined error handler. So I thought a little bit about it and maybe you have better approaches or solutions...

With the goal of emailing the developers when such an error is thrown, he comes up with three different "storage methods" - using syslog, sapi, or a common logfile - and two different methods for watching them - file watching and syslogger. He works through these two options, trying to figure out which out be the simplest to implement.

He comes to the conclusion, though, that he might just be better off with one of the packages already out there to do something similar. Of the four he found, Swatch seemed to fit the best. He includes configuration and setup info to illustrate.

0 comments voice your opinion now!
fatal error realtime logger syslogger swatch email developer fatal error realtime logger syslogger swatch email developer


DevShed:
Expanding an Error Logger with the Chain of Responsibility Pattern
November 13, 2006 @ 10:57:00

Finishing off their look at the "chain of responsibility", DevShed has posted part three of the series - expanding on the code that they produced in the past, they add more functionality to their error logger.

Now, paying attention to the topics that will be covered in this tutorial, what you'll learn here will consist essentially of applying the chain of responsibility schema to expand the capacity of the error logging system that was developed previously.

They take a look back at what they produced in the previous tutorial (the simple error logger) and show how to expand on it by adding functionality to log errors to a file. The finish it off by showing how to implement it all in a simple script.

0 comments voice your opinion now!
error logger chainofresponsibility pattern expand error logger chainofresponsibility pattern expand



Community Events





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


security version library opinion introduction laravel update mvc symfony composer release tool series community voicesoftheelephpant language podcast interview package framework

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