<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 19 Jun 2013 11:34:23 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPClasses.org: 10 Steps to properly do PHP Bug Tracking and Fixing as Fast as possible]]></title>
      <guid>http://www.phpdeveloper.org/news/19650</guid>
      <link>http://www.phpdeveloper.org/news/19650</link>
      <description><![CDATA[<p>
On the PHPClasses.org blog today <i>Manuel Lemos</i> has shared some advice on <a href="http://www.phpclasses.org/blog/package/1351/post/1-10-Steps-to-properly-do-PHP-Bug-Tracking-and-Fixing-as-Fast-as-possible.html">tracking and fixing bugs</a> and some strategies to help prevent them in the future.
</p>
<blockquote>
No matter how hard you try to test your PHP applications before putting them in production, you will always ship code to your server that has bugs. Some of those bugs will be very serious and need to be fixed before they cause greater damages to your application data that may be too hard to recover. Read this article to learn about a several good practices that you can apply to track bugs in production code, so you can fix them before it is too late.
</blockquote>
<p>Suggestions included in his list are things like:</p>
<ul>
<li>Test as Much as Possible Before in your Development Environment
<li>Separate your Code from Environment Configuration files
<li>Track PHP Errors with Assertion Condition Tests
<li>Send PHP Errors to an Error Log File
<li>Monitor the PHP Error Log File to Quickly Fix Serious Bugs
<li>Fix Your Bugs but Never Edit Code on the Production Server
</ul>
<p>
He also includes a brief look at some things to think about when considering "defensive coding practices" and links to other articles with more information.
</p>
Link: http://www.phpclasses.org/blog/package/1351/post/1-10-Steps-to-properly-do-PHP-Bug-Tracking-and-Fixing-as-Fast-as-possible.html]]></description>
      <pubDate>Thu, 30 May 2013 11:49:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen: Simple logging of ZF2 exceptions]]></title>
      <guid>http://www.phpdeveloper.org/news/19507</guid>
      <link>http://www.phpdeveloper.org/news/19507</link>
      <description><![CDATA[<p>
In <a href="http://akrabat.com/zend-framework-2/simple-logging-of-zf2-exceptions/">this new post to his site</a> <i>Rob Allen</i> shows you how to implement a simple logging method for catching exceptions in your Zend Framework 2 application.
</p>
<blockquote>
I recently had a problem with a ZF2 based website where users were reporting seeing the error page displayed, but I couldn't reproduce in testing. To find this problem I decided to log every exception to a file so I could then go back and work out what was happening. In a standard ZF2 application, the easiest way to do this is to add a listener to the 'dispatch.error' event and log using ZendLog.
</blockquote>
<p>
He uses an event listener to attach a service that contains a "logException" method. This method uses the ZendLog component to write out the error message to a local log file including a backtrace of where the issue occurred.
</p>
Link: http://akrabat.com/zend-framework-2/simple-logging-of-zf2-exceptions]]></description>
      <pubDate>Thu, 25 Apr 2013 10:31:40 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Logging with PSR-3 to Improve Reusability]]></title>
      <guid>http://www.phpdeveloper.org/news/19148</guid>
      <link>http://www.phpdeveloper.org/news/19148</link>
      <description><![CDATA[<p>
On PHPMaster.com <i>Patrick Mulvey</i> has written up a new  tutorial looking at <a href="http://phpmaster.com/logging-with-psr-3-to-improve-reusability/">using the PSR-3 logging structure</a> to make a basic logger for your application.
</p>
<blockquote>
Logging is one of the most ubiquitous tasks encountered in PHP. We use logs to track error messages, record important events, and debug problems with our code. In any PHP project, the code is likely to be full of calls to a logging library which handles these actions for us. [...] To promote compatibility between logging libraries, the PHP-FIG group recently released PRS-3, a common interface for logger objects. In this article, I'll discuss how the logger interface defined by PSR-3 allows us to write reusable code that isn't dependent on any particular logging implementation.
</blockquote>
<p>
He includes a quick introduction to the PSR-3 format, how to get the files you'll need to use it (via Composer). He includes some sample code showing how to make the basic email class with a logger injected for use. Since the Monolog logging project follows the PSR-3 format, it's an easy drop-in option. He also talks about using PSR-3 to avoid having logger dependencies with the "LoggerInterface". There's also a bit at the end of the tutorial showing you how to use the Adapter design pattern to "proxy" the logging calls to the class via a PSR-3 interface.
</p>]]></description>
      <pubDate>Thu, 07 Feb 2013 10:22:26 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Community News: PSR-3 Accepted - Logger Interface]]></title>
      <guid>http://www.phpdeveloper.org/news/19037</guid>
      <link>http://www.phpdeveloper.org/news/19037</link>
      <description><![CDATA[<p>
The PHP-FIG  (Framework Interoperability Group) has recently <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md">accepted the PSR-3 definition</a> for a standardized Logger interface structure that can be used for interoperability between frameworks (and other tools).
</p>
<blockquote>
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.
</blockquote>
<p>
The <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md">implementation of this structure</a> 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 <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md">PSR-1</a> and <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md">PSR-2</a> more related to coding standards.
</p>]]></description>
      <pubDate>Tue, 15 Jan 2013 10:55:01 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Cook: Turbocharging your Logs]]></title>
      <guid>http://www.phpdeveloper.org/news/18550</guid>
      <link>http://www.phpdeveloper.org/news/18550</link>
      <description><![CDATA[<p>
In a new post to his site <i>Jeremy Cook</i> <a href="http://jeremycook.ca/2012/10/02/turbocharging-your-logs/">introduces you to Graylog2</a>, a <a href="http://graylog2.org/">logging server</a> that can aggregate messages from multiple sources/feeds into one consolidated location.
</p>
<blockquote>
Graylog stores them in a database and allows you to perform custom searches on them. You can also see in real time how many log messages are being received and processed. The real killer feature in Graylog is streams. A stream in Graylog is a predefined custom search. The server will display to you log messages that only match the stream criteria selected, graphing the results for you. 
</blockquote>
<p>
He mentions other features of the Graylog2 system including customized alerts, messaging via UDP/AMQP and how it uses MongoDb and ElasticSearch. He also introduces <a href="https://github.com/Seldaek/monolog">Monolog</a>, a PHP tool that lets you log in multiple formats directly to the Graylog2 server. He includes an example of how it works with a sample "LoggingHelper" added as custom <a href="set_exception_handler">exception</a> and <a href="set_error_handler">error</a> handlers.
</p>]]></description>
      <pubDate>Wed, 03 Oct 2012 10:07:30 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Scott Mattocks: L is for Logging (LUCID)]]></title>
      <guid>http://www.phpdeveloper.org/news/18509</guid>
      <link>http://www.phpdeveloper.org/news/18509</link>
      <description><![CDATA[<p>
<i>Scott Mattocks</i> has started off his series about the LUCID development methodology (one he <a href="http://crisscott.com/2012/09/11/lucid-development/">recently proposed</a>) with the first article covering <a href="http://crisscott.com/2012/09/21/l-is-for-logging/">"L" for Logging</a>.
</p>
<blockquote>
Communication is the only way you can tell if an application is feeling well or is about to fall apart. If your application can't talk to you, you have no way of helping it to feel better. The L in <a href="http://crisscott.com/2012/09/11/lucid-development/">LUCID</a> is for logging. Logs are how applications speak. They capture information that allows us to pick up on those little signs and act early enough to make sure the application doesn't come down with the flu. If you don't have good logging throughout your system, the best you can do is react to your application falling over. A silent application is an application destined to cause midnight surprises for you and your operations team.
</blockquote>
<p>
He talks about the difference between "just logging" and "correct logging" as well as a recommendation for the different levels: trace, debug, info, warn and error. 
</p>
<blockquote>
Letting you know that something went wrong is really only half of a log messages job. The other responsibilities of a log message are to allow you to accurately reproduce the conditions under which the event occurred, and to allow you to fix any data inconsistencies.
</blockquote>]]></description>
      <pubDate>Mon, 24 Sep 2012 09:23:57 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Hartjes' Blog: Have a 'Strategy']]></title>
      <guid>http://www.phpdeveloper.org/news/17966</guid>
      <link>http://www.phpdeveloper.org/news/17966</link>
      <description><![CDATA[<p>
In response to <a href="http://odino.org/use-the-strategy-to-avoid-the-switch-case-antipattern/">this suggestion</a> from <i>Alessandro Nadalin</i> about using the "Strategy" design pattern to replace a <a href="http://php.net/switch">switch</a. statement, <i>Chris Hartjes</i> has <a href="http://www.littlehart.net/atthekeyboard/2012/05/15/have-a-strategy/">this new post</a> sharing his opinion of "the right way" do it it.
</p>
<blockquote>
Once I realized what he was doing, I realized that the Strategy pattern was applicable in this case…but his chosen example was dumb and one that I wouldn't have used to demonstrate things. As expected, he told me to supply a sample of a better way. I did, telling him that the sample would be better if he didn't mash the logging level together with the message.
</blockquote>
<p>
Included in the post is sample code, first showing the initial version of the logging class, complete with accompanying tests. Following that, he shows how to refactor it into something using the Strategy pattern, replacing the logging type switch statement with protected methods for each logging message type (critical, notice, etc). 
</p>]]></description>
      <pubDate>Wed, 16 May 2012 10:42:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Error Logging with MongoDB and Analog]]></title>
      <guid>http://www.phpdeveloper.org/news/17715</guid>
      <link>http://www.phpdeveloper.org/news/17715</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial from <i>Lorna Mitchell</i> introducing you to <a href="http://phpmaster.com/error-logging-with-mongodb-and-analog/">using Analog for error logging</a> in a MongoDb connection. Because of the way the tool (<a href="https://github.com/jbroadway/analog">Analog</a>) is designed, it could be used anywhere - she just uses the MongoDB connection as an example because it integrates easily and efficiently.
</p>
<blockquote>
<p>
MongoDB is an excellent fit for logging (and of course other things as well) for many reasons. For one, it is very VERY fast for writing data. It can perform writes asynchronously; your application wont hang because your logging routines are blocked. This allows you to centralize your logs which makes it easier to querying against them to find issues. Also, its query interface is easy to work with and is very flexible. You can query against any of the field names or perform aggregate functions either with map/reduce or MongoDB 2.2's upcoming aggregation framework.
</p>
<p>
This article will show how you can use existing code to add a logging library to your code and log errors to MongoDB. You'll also see how to query MongoDB from the command line and how to filter those queries to find the information you are interested in.
</p>
</blockquote>
<p>
Analog makes it simple to log information in an easy to use, self-contained, extensible kind of way, offering writers for multiple output formats including: files, the FirePHP plugin output, email, POSTing to another machine and sending to a syslog daemon. She also mentions the different logging levels the tool makes available and how to filter down your logging results based on them (searched by "equal to", "greater than" and grouped by level).
</p>]]></description>
      <pubDate>Thu, 22 Mar 2012 11:11:39 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ryan Gantt's Blog: Horizontal reusability with traits in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/16765</guid>
      <link>http://www.phpdeveloper.org/news/16765</link>
      <description><![CDATA[<p>
<i>Ryan Gantt</i> has a new tutorial posted to his blog today looking at one of the features in the upcoming PHP 5.4.x releases - traits. Specifically he looks at the <a href="http://zuttonet.com/articles/php-class-traits/">horizontal reusabillity</a> they allow for in your applications.
</p>
<blockquote>
The ability for a class to inherit from multiple parents is maligned by many, but can be a good thing in some situations. For those working in PHP, multiple inheritance has never been an option; classes are limited to one parent, though they can implement many other datatypes through the use of interfaces. Interfaces can lead to code duplication in improperly-factored inheritance hierarchies. Even in well-architected hierarchies, multiple classes that implement similar methods can contain a lot of overlap.
</blockquote>
<p>
He starts with a definition of what traits are and where their real usefulness is (as well as what should be the difference between a class and a trait). He gives an example of a typical hierarchy where two classes extend a parent but then they both need the same functionality. Code duplication's not a possibility and inheritance make run into exposure issues. Traits come to the rescue by dropping in just the feature you need when you need it. His example code shows adding some logging to a simple class via a "Logging" trait and a "Singleton trait" example.
</p>]]></description>
      <pubDate>Wed, 24 Aug 2011 10:42:42 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Dave Marshall's Blog: Traits in PHP 5.4 - HelloWorld with Logging Trait]]></title>
      <guid>http://www.phpdeveloper.org/news/16685</guid>
      <link>http://www.phpdeveloper.org/news/16685</link>
      <description><![CDATA[<p>
<i>Dave Marshall</i> is already looking ahead to the next major release of PHP, version 5.4, and one of the features it will include - traits. In <a href="http://www.davedevelopment.co.uk/2011/08/06/traits-in-php-5-4-helloworld-with-logging-trait/">this new post</a> to his blog, he introduces a "logging trait" he's come up with to make logging simpler in your (Zend Framework) application.
</p>
<blockquote>
One of the 'traits' I find myself constantly adding to library files is optional logging of it's behaviour. The library class has it's own log method, that checks to see if the instance has had a logger injected and if so, logs the message. I see this as a perfect candidate for becoming a reusable trait, as I tend to have the same code copy/pasted throughout my library classes. The problem is, according to the <a href="https://wiki.php.net/rfc/traits">rfc</a>, traits aren't supposed to have state/properties, which makes it difficult to have a DI setter method in a trait. 
</blockquote>
<p>
He includes the code for his trait example (noting that it may or may not end up working correctly in the 5.4 final release) that sets a logger on a sample class and logs a few values out to the console. It's a simple example, but it shows you one of the most useful things about traits - the "drop in resuability" nature they allow in your libraries and classes.
</p>]]></description>
      <pubDate>Mon, 08 Aug 2011 10:24:36 -0500</pubDate>
    </item>
  </channel>
</rss>
