<?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>Thu, 23 May 2013 06:36:20 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Bulletproofing Database Interactions with PHPUnit's Database Extension]]></title>
      <guid>http://www.phpdeveloper.org/news/17794</guid>
      <link>http://www.phpdeveloper.org/news/17794</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial showing you how to <a href="http://phpmaster.com/bulletproofing-database-interactions">test your application's interface with the database</a> using "bulletproof" PHPUnit testing.
</p>
<blockquote>
There's already a great article here that discusses Test Driven Development, but did you know that you can also test the code that interacts with your database? Especially if your application is data intensive, subjecting your CRUD code to a battery of tests is good practice that helps ensure that your application is working correctly. In this article you will be learning how to write database tests in PHP using PHPUnit and its database extension. 
</blockquote>
<p>
Included in the post is an <a href="https://github.com/phpmasterdotcom/BulletproofingDatabaseInteractions/blob/master/schema.sql">example schema</a> and an example of the seed data (defined as XML) for the testing to use as predictable data in its execution. His test class extends <i> PHPUnit_Extensions_Database_TestCase</i> (instead of the usual <i>PHPUnit_Framework_TestCase</i>) and a test for a basic "getArticles" method in his "IArticleDAO" class. By calling the "createXMLDataSet" method, the test loads in the pre-defined XML records and allows the correct evaluation of the assertions,
</p>]]></description>
      <pubDate>Tue, 10 Apr 2012 08:50:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[IBM developerWorks: Store datasets directly in shared memory with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17426</guid>
      <link>http://www.phpdeveloper.org/news/17426</link>
      <description><![CDATA[<p>
On the IBM developerWorks site today there's a new tutorial showing you how to <a href="http://www.ibm.com/developerworks/opensource/library/os-php-shared-memory/index.html">store shared data</a> directly to a shared memory space of your PHP application.
</p>
<blockquote>
Once created, and given proper permissions, other processes in the same machine can manipulate those segments by: read, write, and delete. This means that an application written in C can share information with an application written in other languages, such as Java or PHP. They can all share information, as long as they can access and understand that information. [...] This article's proposal is simple, learn how to create and manipulate shared memory segments with PHP and use them to store datasets that other applications can use.
</blockquote>
<p>
Your PHP installation will need to have been compiled with "enable-shmop" to work with the code in this tutorial. Their examples show how to use the <a href="http://php.net/shmop_open">shmop_open</a>, <a href="http://php.net/shmop_write">shmop_write</a> and other related functions to read, write, remove and close segments in the shared memory space. They also include an example of using the <a href="https://github.com/klaussilveira/SimpleSHM">SimpleSHM</a> library to make it easier to interact with the shared memory space as a standard storage location.
</p>]]></description>
      <pubDate>Fri, 20 Jan 2012 11:29:24 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Learning Loops]]></title>
      <guid>http://www.phpdeveloper.org/news/17264</guid>
      <link>http://www.phpdeveloper.org/news/17264</link>
      <description><![CDATA[<p>
PHPmaster.com has a new introductory tutorial for those just starting out with PHP (or with programming really) talking about <a href="http://phpmaster.com/loops/">using looping structures</a> for sets of data - for, while/do-while and foreach.
</p>
<blockquote>
A significant advantage of computers is that they can perform repetitive tasks easily and efficiently. Instead of writing repetitive code you can write a set of statements that processes some data and then have the computer execute them repeatedly by using a construct known as a loop. Loops come in several different flavors in PHP: for, while, do-while, and foreach. I'll introduce you to each of them and show you how they can making repetitive tasks straightforward and easy to maintain.
</blockquote>
<p>
The tutorial explains a use case for each of the loop types and includes a bit of sample code showing how to put it into practice. It also shares two special keywords that can be used to bypass or break out of your current loop - break and continue.
</p>]]></description>
      <pubDate>Thu, 15 Dec 2011 10:15:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Martin Sikora's Blog: Storing arrays using JSON, serialize and var_export]]></title>
      <guid>http://www.phpdeveloper.org/news/16692</guid>
      <link>http://www.phpdeveloper.org/news/16692</link>
      <description><![CDATA[<p>
<i>Martin Sikora</i> was working on an application that used a large dataset (in an array) and <a href="http://www.martinsikora.com/storing-arrays-using-json-serialize-and-var-export">found some interesting things</a> in regards to PHP's resulting loading time and saving time in four different types of arrays.
</p>
<blockquote>
Recently I was dealing with precessing and storing large arrays in PHP (around 100 000 items) and I found out some quiet surprising facts that are very useful in performance critical applications. [...] When I started looking for some benchmark I found article Cache a large array: JSON, serialize or var_export?. That is really good but I wanted to compare a few more things.
</blockquote>
<p>
He tested with four different array types including associative with an integer value and numeric index with a string value at sizes of 10, 100, 1,000 and 10,000 items. He ran his tests with the <a href="http://php.net/json_encode">json</a> <a href="http://php.net/json_decode">methods, <a href="http://php.net/serialize">serializing</a> them and a <a href="http://php.net/var_export">var_export</a>. There's <a href="http://www.martinsikora.com/storing-arrays-using-json-serialize-and-var-export?">graphs of his results</a> for each included in the post with some interesting variations between the different array types.
</p>]]></description>
      <pubDate>Tue, 09 Aug 2011 09:31:51 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: The PHP Ternary Operator: Fast or not?]]></title>
      <guid>http://www.phpdeveloper.org/news/16601</guid>
      <link>http://www.phpdeveloper.org/news/16601</link>
      <description><![CDATA[<p>
In a new post <i>Fabien Potencier</i> looks at <a href="http://fabien.potencier.org/article/48/the-php-ternary-operator-fast-or-not">the ternary operator</a> in PHP and wonders which is faster - using it or not (well, sort of...)
</p>
<blockquote>
People like micro-optimizations. They are easy to understand, easy to apply... and useless. But some time ago, while reviewing pull requests for <a href="http://twig-project.org/">Twig</a>, I read an interesting discussion about the performance of the <a href="https://github.com/fabpot/Twig/issues/380">ternary operator</a> in PHP (thanks to <a href="https://github.com/nikic">@nikic</a> for the investigation). Do you know which [example] snippet is the fastest (of course, they do exactly the same)? The right answer is: it depends.
</blockquote>
<p>
He notes that it's all about the data being worked with. As some of his tests show (testing code included) there does end up being a difference between using it on a small and large dataset. After investigation, it was found that the ternary operator copies (copy-on-write) the value versus an "if" that just evaluates. He also mentions the new "?" version of the ternary syntax in PHP 5.3, but notes it still suffers from the same issue.
</p>
]]></description>
      <pubDate>Mon, 18 Jul 2011 10:35:36 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[MySQL Performance Blog: Sample datasets for benchmarking and testing]]></title>
      <guid>http://www.phpdeveloper.org/news/15881</guid>
      <link>http://www.phpdeveloper.org/news/15881</link>
      <description><![CDATA[<p>
In <a href="http://www.mysqlperformanceblog.com/2011/02/01/sample-datasets-for-benchmarking-and-testing/">a recent post</a> to the MySQL Performance Blog, there's a pointer to a few resources you can use if you need some sample datasets to run your application against - everything from airline flight information to energy usage data.
</p>
<blockquote>
Sometimes you just need some data to test and stress things. But randomly generated data is awful - it doesn't have realistic distributions, and it isn't easy to understand whether your results are meaningful and correct. Real or quasi-real data is best. Whether you're looking for a couple of megabytes or many terabytes, the following sources of data might help you benchmark and test under more realistic conditions.
</blockquote>
<p>
The sample data sets vary from <a href="http://forge.mysql.com/wiki/SakilaSampleDB">fake movie information</a> to sample <a href="http://dammit.lt/wikistats/archive/">site traffic data</a> to the <a href="http://aws.amazon.com/publicdatasets/">large data sets</a> that Amazon provides (including the Human Genome and US Census data). Some of <a href="http://www.mysqlperformanceblog.com/2011/02/01/sample-datasets-for-benchmarking-and-testing/#comments">the comments</a> also link to other sources.
</p>]]></description>
      <pubDate>Wed, 09 Feb 2011 13:19:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Paul Reinheimer's Blog: Memory usage in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14225</guid>
      <link>http://www.phpdeveloper.org/news/14225</link>
      <description><![CDATA[<p>
<i>Paul Reinheimer</i> has a reminder shown in his latest post about optimizing your scripts - don't forget <a href="http://blog.preinheimer.com/index.php?/archives/354-Memory-usage-in-PHP.html">the basics like unset</a>.
</p>
<blockquote>
A colleague called me over today for some help with a memory usage issue in his PHP script. The script was performing the basic (but critical) task of importing data, pulling it in from MySQL in large chunks, then exporting it elsewhere. He was receiving the wonderful "Fatal error: Allowed memory size of XXXX bytes exhausted (tried to allocate YY bytes)" error message. [...] I fixed the memory usage exceeded problem with an unset(), at the end of a loop.
</blockquote>
<p>
The loop was structured such that the large amounts of data were just being held in memory over and over again, resulting in a huge stackup that can easily cause the "Allowed memory size exhausted..." message.
</p>
<blockquote>
There are better architectures available to avoid the issue entirely (like not storing everything in the array, just to iterate over it later) but they're an issue for a different post. For a very simple base case demonstration of the issue take a look at the <a href="http://example.preinheimer.com/memory-usage-simple-example.php">simple example</a>.
</blockquote>]]></description>
      <pubDate>Mon, 22 Mar 2010 12:09:52 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Mike Lively's Blog: YAML Now Supported by PHPUnit Database Extension]]></title>
      <guid>http://www.phpdeveloper.org/news/11853</guid>
      <link>http://www.phpdeveloper.org/news/11853</link>
      <description><![CDATA[<p>
<i>Mike Lively</i> <a href="http://www.ds-o.com/archives/79-YAML-Now-Supported-by-PHPUnit-Database-Extension.html">has posted</a> about a new bit of support that the <a href="http://phpunit.de">PHPUnit</a> unit testing software for PHP has just gotten - YAML data set parsing.
</p>
<blockquote>
I have now just committed <a href="http://www.ds-o.com/exit.php?url_id=246&entry_id=79">YAML</a> data sets to the Database Extension for <a href="http://www.ds-o.com/exit.php?url_id=247&entry_id=79">PHPUnit</a>. So now all those that love the simplicity and straightforwardness of YAML can use it with your data sets. I have also created a persistor for YAML datasets so you can easily convert existing data sets or database data into YAML representations.
</blockquote>
<p>
He includes an example of a bit of YAML markup and one of the major hurdles he had to overcome - trailing line breaks (as shown in the table_2/column 8 in the example). This functionality also includes a persistor that lets you convert things back the other day - current data set to YAML markup. You can find out more about data sets in PHPUnit in <a href="http://www.phpunit.de/manual/current/en/database.html#database.datasets">this section</a> of the project's manual.
</p>]]></description>
      <pubDate>Mon, 02 Feb 2009 07:52:31 -0600</pubDate>
    </item>
  </channel>
</rss>
