<?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 13:40:15 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Segment.io: How to Make Async Requests in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19142</guid>
      <link>http://www.phpdeveloper.org/news/19142</link>
      <description><![CDATA[<p>
On the Segment.io blog there's a new post by <i>Calvin</i> talking about <a href="https://segment.io/blog/how-to-make-async-requests-in-php/">making asyncronous requests in PHP</a> and three different approaches you could use, depending on your situation.
</p>
<blockquote>
When designing client libraries to send data to our API, one of our top priorities is to make sure that none of our code affects the performance of your core application. That is tricky when you have a single-threaded, "shared-nothing" language like PHP. [...] Ideally, we like to keep the setup process minimal and address a wide variety of use cases. As long as it runs with PHP (and possibly a common script or two), you should be ready to dive right in. We ended up experimenting with three main approaches to make requests in PHP. Here's what we learned.
</blockquote>
<p>
Their three suggestions don't involve external dependencies (like a queue server) and can operate pretty quickly:
</p>
<ul>
<li>Opening a socket and closing it before waiting for a response
<li>Write to a log file (a pseudo-queue)
<li>Fork a curl process (through something like <a href="http://php.net/exec">exec</a>)
</ul>
<p>
They each have small code examples included with them and explanations as to their plusses and minuses. For their needs, the "forked curl" solution worked out the best, but check out the other options too - you might have different needs.
</p>]]></description>
      <pubDate>Wed, 06 Feb 2013 09:52:49 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Bob Majdak: Apache access logging in JSON format]]></title>
      <guid>http://www.phpdeveloper.org/news/18277</guid>
      <link>http://www.phpdeveloper.org/news/18277</link>
      <description><![CDATA[<p>
<i>Bob Majdak</i> has a quick new post to his site showing you how to <a href="http://catch404.net/2012/07/apache-access-logging-in-json-format/">log messages to Apache</a> using a JSON format instead of the usual single-line information.
</p>
<blockquote>
So this past week I have been doing a lot of logging, parsing, and graphing. I was sitting there wondering what I could do to make the Apache access logs easier to work with. Then it hit me, a brilliant stroke of win: why not format it in JSON? Then in my log parser I could just json_decode it! As far as I know there are no tricks to make Apache do this for you, so really all we have to do is define a custom log format that happens to look like JSON.
</blockquote>
<p>
He includes the "LogFormat" line you'll need to add to your Apache configuration to make it log the JSON and a bit of PHP to help you pull in the file's contents and <a href="http://php.net/json_decode">parse</a> each line.
</p>]]></description>
      <pubDate>Thu, 26 Jul 2012 11:42:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: Check for a TTY or interactive terminal in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16809</guid>
      <link>http://www.phpdeveloper.org/news/16809</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Brian Moon</i> describes a need he had for detecting if the client or user calling a PHP script was <a href="http://brian.moonspot.net/tty-or-interactive-terminal-in-php">using an interactive terminal (TTY)</a> or not:
</p>
<blockquote>
Let's say I am trying to find out why some file import did not happen. Running the job that is supposed to do it may yield an error. Maybe it was a file permission issue or something. There are other people watching the alerts. What they don't know is that I am running the code and looking at these errors in real time.
</blockquote>
<p>
Since the errors were being sent to the log file, they were lost to the client/user on the other end left staring at their script wondering what went wrong. He ended up with a solution (a pretty simple one too) that uses <a href="http://www.php.net/posix_ttyname">posix_ttyname</a> and <a href="http://php.net/posix_isatty">posix_isatty</a>. He includes the little snippet of code he puts in his prepend file that checks for errors then checks for a TTY. If both are there, it turns off logging the errors to the file and sends them direct instead.
</p>]]></description>
      <pubDate>Fri, 02 Sep 2011 09:12:47 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Tail functionality in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16606</guid>
      <link>http://www.phpdeveloper.org/news/16606</link>
      <description><![CDATA[<p>
<i>Sameer Borate</i> has posted <a href="http://www.codediesel.com/php/tail-functionality-in-php/">an alternative to "tail"</a> that you can use to find the last X number of lines in a log file you'd like to follow without having the overhead of parsing the entire file.
</p>
<blockquote>
Frequently one needs to get the last few lines of some log files, whether php error logs or Apache logs. Most of these file sizes run into megabytes, which makes it difficult and time consuming to remotely open them using ftp. [...] The [example] is a simple but useful 'tail' implementation in PHP. I've encapsulated the tail function in a 'LogRead' class, which can be further enlarged by adding other useful log functions.
</blockquote>
<p>
His code opens a file pointer to the requested log, grabs the file size and uses the <a href="http://php.net/fseek">fseek</a> function to move the pointer to the line/location you've requested. Obviously, if the requested lines of data is large, it will still have some overhead, but this is a much better way for keeping track of the latest additions to a log. You can then use the "tail" method on the "LogRead" class to grab just the lines you want.
</p>]]></description>
      <pubDate>Tue, 19 Jul 2011 10:16:41 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Josh Adell's Blog: Logging User Sessions Across Requests]]></title>
      <guid>http://www.phpdeveloper.org/news/16366</guid>
      <link>http://www.phpdeveloper.org/news/16366</link>
      <description><![CDATA[<p>
<i>Josh Adell</i> has a new post to the Everyman Software blog talking about a solution he and his team have developed for <a href="http://blog.everymansoftware.com/2011/05/logging-user-sessions-across-requests.html">logging user sessions across requests</a> with the help of the Zend_Log component and a custom logging formatter.
</p>
<blockquote>
One way to handle this is to put a request-specific identifier in every log message. But I shouldn't have to remember to append or prepend the identifier to their log messages. I'd rather have it happen automatically, without me or my teammates having to think about it. Here's a method we've been using to try and untangle the mess and retain the usefulness of our logs. The code uses Zend's logging component, but can easily be adapted to other log systems.
</blockquote>
<p>
Their example sets a custom log format message with placeholders for a timestamp, log ID number and the log message. A unique ID is then generated for the user's session and applied to the Zend_Log object. This data is then automatically applied to the log file's output without any extra hassle. The full sample code (pretty simple, really) is included.
</p>]]></description>
      <pubDate>Fri, 20 May 2011 09:10:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Working Software Blog: Parsing the output of PHPs print_r function]]></title>
      <guid>http://www.phpdeveloper.org/news/15744</guid>
      <link>http://www.phpdeveloper.org/news/15744</link>
      <description><![CDATA[<p>
On the Working Software blog there's <a href="http://workingsoftware.com.au/page/Parsing_the_output_of_PHPs_printr_function">a recent post</a> looking at correcting a mistake that the developer made when choosing the logging method of his application - pushing the output of <a href="http://php.net/print_r">print_r</a> into a file.
</p>
<blockquote>
 recently deployed a job on which the timeline was so tight that my ability to type quickly was what made the difference between delivering on time or not. Everything was rushed, the budget was tight, it was one of those real seat of the pants deals and there was far too little testing done. [...] The only problem is that, in the 5 minutes before the site was supposed to go live, I didn't really have much time to thoughtfully prepare a logging system to record all this stuff and, in my haste, I settled for [a file_put_contents of the print_r of $_GET and $_POST].
</blockquote>
<p>
Obviously, this solution is useful for casual browsing of the information, but if you need any real data from it, it's a real chore. To help you with the task, they've put together a snippet of code that can work through your print_r output and return it in a much more handy line-by-line result. Full code is copy-and-paste ready in <a href="http://workingsoftware.com.au/page/Parsing_the_output_of_PHPs_printr_function">the post</a>.
</p>]]></description>
      <pubDate>Fri, 14 Jan 2011 12:19:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: Quick Tip: Email Error Logs with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15674</guid>
      <link>http://www.phpdeveloper.org/news/15674</link>
      <description><![CDATA[<p>
In <a href="http://net.tutsplus.com/tutorials/php/quick-tip-email-error-logs-to-yourself-with-php">this quick tip</a> from NetTuts.com today they show you how to set up custom error logging for your PHP application with the help of the <a href="http://php.net/set_error_handler">set_error_handler</a> function.
</p>
<blockquote>
In today's video quick tip, we'll review the process of setting custom error handlers with PHP. Along the way, we'll also learn how to log and email those potential errors to ourselves. That way, even when your web application has been deployed, you'll be the first to know when an error is encountered.
</blockquote>
<p>
They make a custom handler, nettuts_error_handler, that takes in the error information and translates it into an error message that's emailed to an admin of the site. It also checks the error reporting level to see if it needs to display the error back to the user or not. This helpful hint is part of a screencast, but they've provided the code separately to make it easier to work with. 
<p>]]></description>
      <pubDate>Tue, 04 Jan 2011 08:58:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Design-Ireland.net: Logging Messages to Scribe from PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15462</guid>
      <link>http://www.phpdeveloper.org/news/15462</link>
      <description><![CDATA[<p>
On the Design-Ireland.net site, there's a recent tutorial showing you how to <a href="http://www.design-ireland.net/article/Logging_Messages_to_Scribe_from_PHP">log messages to Scribe from PHP</a>. <a href="https://github.com/facebook/scribe">Scribe</a> is Facebook's open sourced server for aggregating log data streamed in from multiple places.
</p>
<blockquote>
n a previous tutorial, I showed you how to install Facebook Scribe on a Linux server. In this tutorial we will continue to look at Scribe, but this time from the client perspective. Note that this tutorial assumes that you already have your Scribe and Thrift environment set up as outlined in the <a href="http://www.design-ireland.net/article/Installing_Facebook_Scribe_on_Fedora_8">previous tutorial</a>. You can log messages to Scribe from many different languages. In this tutorial I will show you how to use Thrift to generate a PHP client, and then use that client from your own PHP project to log messages.
</blockquote>
<p>
The tutorial walks you through setting up Thrift to work with your PHP installation and gives an example script to send your first messages over to the Scribe server. They also show how you can go into the Scribe instance's folders and look for the log information you just inserted.
</p>]]></description>
      <pubDate>Fri, 19 Nov 2010 10:28:32 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: Monitoring PHP Errors]]></title>
      <guid>http://www.phpdeveloper.org/news/15404</guid>
      <link>http://www.phpdeveloper.org/news/15404</link>
      <description><![CDATA[<p>
<i>Brian Moon</i> has <a href="http://brian.moonspot.net/monitoring-php-errors">a new post</a> to his blog that pulls together some of his thoughts on monitoring PHP applications and how to handle the error that might be thrown.
</p>
<blockquote>
PHP errors are just part of the language. Some internal functions throw warnings or notices and seem unavoidable. A good case is parse_url. The point of parse_url is to take apart a URL and tell me the parts. Until recently, the only way to validate a URL was a regex. You can now use filter_var with the FILTER_VALIDATE_URL filter. But, in the past, I would use parse_url to validate the URL. It worked as the function returns false if the value is not a URL. But, if you give parse_url something that is not a URL, it throws a PHP Warning error message. The result is I would use the evil @ to suppress errors from parse_url. Long story short, you get errors on PHP systems. And you don't need to ignore them.
</blockquote>
<p>
He talks about the two-step process he's upgraded to to help monitor and handle the errors that pop up - an <a href="http://us.php.net/manual/en/function.set-error-handler.php">error handler</a> that logs human-readable and json versions of the errors and something like <a href="http://circonus.com/">Circonus</a> to do metric tracking. He also mentions some external services recommended on twitter - <a href="http://hoptoadapp.com/">HopToad</a> and <a href="http://www.loggly.com/">Loggly</a>.
</p>]]></description>
      <pubDate>Tue, 09 Nov 2010 11:09:16 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[ServerGrove Blog: Logging MongoDB queries using Symfony 2 and Doctrine ODM]]></title>
      <guid>http://www.phpdeveloper.org/news/15230</guid>
      <link>http://www.phpdeveloper.org/news/15230</link>
      <description><![CDATA[<p>
On the ServerGrove blog today there's <a href="http://blog.servergrove.com/2010/10/05/logging-mongodb-queries-using-symfony-2-and-doctrine-odm/">a quick new post</a> showing a method you can use to log the queries to your MongoDB database in your Symfony2-based application.
</p>
<blockquote>
Symfony 2 comes with native support to connect to MongoDB using the DoctrineMongoDBBundle. Getting started is quite simple and there is not much that needs to be configured, but the manual does not say how to enable query logging although it is already possible with Symfony PR3. Query logging allows you to debug queries sent to the DB server by writing them in a log file. It is very useful for cases when you issue a query and you are not getting the results you expected. 
</blockquote>
<p>
The key is to add a "logger_class" value into your Symfony configuration file pointing to the "DoctrineMongoDBLogger" tool. The queries will then show up in your normal log files. They include a sample line along with a brief explanation of the values inside.
</p>]]></description>
      <pubDate>Tue, 05 Oct 2010 10:56:43 -0500</pubDate>
    </item>
  </channel>
</rss>
