<?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>Sat, 18 May 2013 13:14:56 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DZone.com: Cloning in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19600</guid>
      <link>http://www.phpdeveloper.org/news/19600</link>
      <description><![CDATA[<p>
In <a href="http://css.dzone.com/articles/cloning-php">this recent post</a> over on DZone.com <i>Giorgio Sironi</i> takes a look at the "clone" feature of PHP - what it is, how it can be used and things to watch out for in its use.
</p>
<blockquote>
Cloning is an operation consisting in the duplication of a data structure, usually to avoid the <a href="http://en.wikipedia.org/wiki/Action_at_a_distance_%28computer_programming%29">aliasing problem</a> of having different code modify the same instance in inconsistent ways. In PHP, cloning can be accomplished in multiple ways - and in some cases it can be avoided altogether.
</blockquote>
<p>
He talks some about how objects are passed around internally during the PHP execution and how you can tell if a function works with data by reference (from the manual). He then looks at the "clone" keyword and what kinds of things are duplicated from an object when it is used. He briefly touches on the "__clone" magic method for solving the "shallow clone" problem and how, possibly, serializing the object might be a better alternative for reproducing the entire object.
</p>
Link: http://css.dzone.com/articles/cloning-php]]></description>
      <pubDate>Fri, 17 May 2013 11:09:42 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: How to Write Testable and Maintainable Code in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19594</guid>
      <link>http://www.phpdeveloper.org/news/19594</link>
      <description><![CDATA[<p>
NetTuts.com has a new tutorial posted suggesting a few ways you can make <a href="http://net.tutsplus.com/tutorials/php/how-to-write-testable-and-maintainable-code-in-php/">testable and maintainable code</a> in PHP applications.
</p>
<blockquote>
Frameworks provide a tool for rapid application development, but often accrue technical debt as rapidly as they allow you to create functionality. Technical debt is created when maintainability isn't a purposeful focus of the developer. Future changes and debugging become costly, due to a lack of unit testing and structure. Here's how to begin structuring your code to achieve testability and maintainability - and save you time.
</blockquote>
<p>
There's a few concepts they cover in the tutorial including DRY (don't repeat yourself), working with dependency injection and actually writing the tests with PHPUnit. They start with a bit of code that needs some work and use the tests to help refactor it into something that can be easily mocked (using <a href="http://net.tutsplus.com/tutorials/php/mockery-a-better-way/">Mockery</a>). 
</p>
Link: http://net.tutsplus.com/tutorials/php/how-to-write-testable-and-maintainable-code-in-php]]></description>
      <pubDate>Thu, 16 May 2013 11:53:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Bob Majdak: On SQL in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19593</guid>
      <link>http://www.phpdeveloper.org/news/19593</link>
      <description><![CDATA[<p>
In a new post to his site <i>Bob Majdak</i> looks at <a href="http://catch404.net/2013/05/on-sql-in-php/">using SQL in PHP</a> and some of the challenges he's come across (some of them with his own tools). He talks about things line inline SQL, loading SQL by unique key or creating a "build object".
</p>
<blockquote>
There is no right or wrong way, but no matter what there is no *pretty* way to do SQL inside of a PHP application. I have been having a personal debate with myself all week about how to make SQL statements nicer in an application without going to a huge DBAL package like Doctrine.
</blockquote>
<p>
He looks at each idea and provides some of the pros and cons about each of them, noting that he hasn't quite decided on which is the best method. Some sample code is included to help clarify the points, showing the "find by unique key" version and how a more complex query might be created with the "builder object."
</p>
Link: http://catch404.net/2013/05/on-sql-in-php]]></description>
      <pubDate>Thu, 16 May 2013 10:11:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Juan Treminio: Unit Testing Tutorial Part V: Mock Methods and Overriding Constructors]]></title>
      <guid>http://www.phpdeveloper.org/news/19416</guid>
      <link>http://www.phpdeveloper.org/news/19416</link>
      <description><![CDATA[<p>
<i>Juan Treminio</i> has posted the <a href="http://jtreminio.com/2013/03/unit-testing-tutorial-part-5-mock-methods-and-overriding-constructors/">latest part of his unit testing series</a> to his site today - the fifth part that looks at using mock methods on mock objects and overriding constructors.
</p>
<blockquote>
Previously in my PHPUnit tutorial series, you learned about the very powerful concept of mock objects and stub methods. This concept is central to successful unit testing, and once it fully 'clicks' in your head you will start to realize how useful and simple testing can be. There is also another thing I want to make clear: creating tests is basically a puzzle - you simply have to go step by step, making sure all the pieces fit together correctly so you can get your green. I hope to make clear what I mean by the end of this tutorial.
</blockquote>
<p>
He assumes you already know about mock objects and introduces the concept of "stub methods" and "mock methods", noting the difference between them. He then gets into what he calls the "four pathways of getMockBuilder" and talks about the rationale behind mocking methods in the first place. He then gets into constructors and how you can work around the "bad" ones with help from mock object functionality. 
</p>
<p>
If you're interested in reading the rest of the series, you can find links to them <a href="http://jtreminio.com/tag/phpunit/">here</a>.
</p>
Link: http://jtreminio.com/2013/03/unit-testing-tutorial-part-5-mock-methods-and-overriding-constructors/]]></description>
      <pubDate>Fri, 05 Apr 2013 09:38:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[TechFlirt: Object Oriented Programming in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19400</guid>
      <link>http://www.phpdeveloper.org/news/19400</link>
      <description><![CDATA[<p>
If you've been writing mostly procedural PHP code and are looking to make that "next step" up to working with objects and classes (OOP), you should check out <a href="http://www.techflirt.com/tutorials/oop-in-php/index.html">this detailed tutorial</a> introducing you to some of the primary OOP-in-PHP concepts.
</p>
<blockquote>
Object oriented programming (OOP) was first introduced in php4. Area for oop in php version 4 was not very vast. There were only few features  available in php4. Major concept of the object oriented programming in PHP is introduced from version 5(we commonly known as php5). [...] But still in php5 object model is designed nicely. If you have good understanding of OOP then you can create very good architecture of your php application.  You only need to know some of the basic principles of object oriented programming and how to implement that concept of oop in php. 
</blockquote>
<p>
While the wording is slightly odd in some spots (English doesn't seem to be the author's first language), it's' a great introduction to the major OOP-related topics including:
</p>
<ul>
<li><a href="http://www.techflirt.com/tutorials/oop-in-php/classes-and-objects-php.html">Classes and Objects</a>
<li><a href="http://www.techflirt.com/tutorials/oop-in-php/visibility-in-php-classes.html">Visibility in PHP</a>
<li><a href="http://www.techflirt.com/tutorials/oop-in-php/abstract-classes-interface.html">Abstract classes and interfaces</a>
<li><a href="http://www.techflirt.com/tutorials/oop-in-php/object-cloning-in-php.html">Object cloning</a>
<li><a href="http://www.techflirt.com/tutorials/oop-in-php/php-method-chaining.html">Method chaining</a>
</ul>
<p>
Each section also has downloadable code to go along with the examples, making it easier to follow and test out the actual scripts.
</p>
Link: http://www.techflirt.com/tutorials/oop-in-php/index.html]]></description>
      <pubDate>Tue, 02 Apr 2013 13:05:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen: Objects in the model layer: Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/19398</guid>
      <link>http://www.phpdeveloper.org/news/19398</link>
      <description><![CDATA[<p>
<i>Rob Allen</i> <a href="http://akrabat.com/development/objects-in-the-model-layer/">previously posted</a> about some of his practices around the different types of objects in the model layer of his Zend Framework 2 applications. In <a href="http://akrabat.com/php/objects-in-the-model-layer-part-2/">this latest post</a> he follows up and shares some example code for the different types.
</p>
<blockquote>
I previously talked about the terms I use for <a href="http://akrabat.com/development/objects-in-the-model-layer/">objects in the model layer</a> and now it's time to put some code on those bones. Note that,as always, all code here is example code and not production-ready.
</blockquote>
<p>
He includes sample classes related to his "books" examples - a "book" entity (with title, author, id and ISBN), a mapper object to load/save/delete the entity and a service object that provides an interface for the entity to the rest of the application.
</p>]]></description>
      <pubDate>Tue, 02 Apr 2013 11:55:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen: Objects in the model layer]]></title>
      <guid>http://www.phpdeveloper.org/news/19350</guid>
      <link>http://www.phpdeveloper.org/news/19350</link>
      <description><![CDATA[<p>
In <a href="http://akrabat.com/development/objects-in-the-model-layer/">this latest post</a> to his site <i>Rob Allen</i> talks some about application structure and the different kinds of objects he uses in his applications.
</p>
<blockquote>
I currently use a very simple set of core objects within my model layer: entities, mappers and service objects. [...] I dislike the phrase "service object" as the word "service" means so many things to so many people. I haven't heard a better phrase yet that everyone understands though.
</blockquote>
<p>
He defines each of the types of objects to help make the separation clearer. Here they are in brief:
</p>
<ul>
<li>Entities are objects that represent something in my business logic.
<li>Mappers know how to save and load an entity from the data store.
<li>Service objects provide the API that the rest of the application uses.
</ul>
<p>
Some of the comments on the post relate his choices to use in Zend Framework v2-based applications, noting that there are some base components you can extend to create these kinds of objects.
</p>]]></description>
      <pubDate>Fri, 22 Mar 2013 10:45:54 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Michelangelo van Dam: Look mama, no databases]]></title>
      <guid>http://www.phpdeveloper.org/news/19325</guid>
      <link>http://www.phpdeveloper.org/news/19325</link>
      <description><![CDATA[<p>
In his most recent post <i>Michelangelo van Dam</i> talks about <a href="http://www.dragonbe.com/2013/03/look-mama-no-databases.html">unit testing and databases</a> and how, to effectively test what should be tested (the code, not "the ability to fetch data") you need to correctly mock your database objects.
</p>
<blockquote>
When I state "as is", I truly mean the way it's being used in production. So the database call collects real data on which business logic is applied. You can see this is not a healthy situation, especially when you also have services that apply business logic on data and store it back into the database. In "<a href="https://leanpub.com/grumpy-phpunit?ref=dragonbe>The Grumpy Programmer's PHPUnit Cookbook</a>", author <a href="https://twitter.com/grmpyprogrammer">Chris Hartjes</a> wrote this one sentence that says it all: "Unit test suites are meant to be testing code, not the ability of a database server to return results". And he's right, you shouldn't use database connections when your testing business rules and functional logic.
</blockquote>
<p>
He goes on to show a few code examples that show a pre-mocked state of testing where the Product information is pulled directly from a PDO connection. The more correct version mocks out this object, though, and overrides the "execute" and "fetchAll" methods to return mocked results. 
</p>]]></description>
      <pubDate>Mon, 18 Mar 2013 10:11:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Simplifying Test Data Generation with Faker]]></title>
      <guid>http://www.phpdeveloper.org/news/19203</guid>
      <link>http://www.phpdeveloper.org/news/19203</link>
      <description><![CDATA[<p>
In a new post to PHPMaster.com today, <i>Rakhitha Nimesh</i> <a href="http://phpmaster.com/simplifying-test-data-generation-with-faker/">takes a look at Faker</a>, a tool that can be used to generate random test case data as a part of your workflow.
</p>
<blockquote>
Testing is an iterative part of the development process that we carry out to ensure the quality of our code. A large portion of this entails writing test cases and testing each unit of our application using random test data. Actual data for our application comes in when we release it to production, but during the development process we need fake data similar to real data for testing purposes. The popular open source library Faker provides us with the ability to generate different data suitable for a wide range of scenarios.
</blockquote>
<p>
Faker uses built-in data providers like "Person", "Company", "DateTime" and "UserAgent" to give you randomized output from the data sets you define. Code is included showing how to create the provider in your objects, extending the correct provider and making a request for a property. A real-world example is also included about testing an email marketing engine for address, title, name and content. There's also a little bit added at the end showing how you can increase the randomness of the results returned by "seeding" the Faker engine.
</p>]]></description>
      <pubDate>Tue, 19 Feb 2013 12:09:02 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Nitschinger: Benchmarking Cache Transcoders in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19117</guid>
      <link>http://www.phpdeveloper.org/news/19117</link>
      <description><![CDATA[<p>
<i>Michael Nitschinger</i> has written up a new post comparing a few different methods for serializing or translating objects to <a href="http://nitschinger.at/Benchmarking-Cache-Transcoders-in-PHP">store them in a cache</a>. In it, he compares the PHP serializer, the <a href="http://pecl.php.net/package/igbinary">igbinary</a> extension and translation to JSON.
</p>
<blockquote>
Storing PHP objects (or simpler data types like arrays) in caches always requires some kind of transformation. You need a way of encoding/decoding data so that it can be stored and loaded properly. In most languages, this process is known as object <a href="http://en.wikipedia.org/wiki/Serialization">serialization</a>. PHP provides a mechanism for this out of the box, but in this article we'll also look at <a href="http://pecl.php.net/package/igbinary">igbinary</a> as a drop-in replacement for the default serializer. We also compare the results to object transcoding based on <a href="http://json.org/">JSON</a>, which is not really an object serialization mechanism but commonly used as a data chache structure which has its own benefits and drawbacks.
</blockquote>
<p>
He goes through each of the three technologies and includes a snippet of code showing how they'd work in object translation. He also talks about things like the size of the result and the performance of each when the results are looped over. Based on the results of some of his "microbenchmarking" of each of the methods, <a href="http://pecl.php.net/package/igbinary">igbinary</a> came out on top, even faster than PHP's own <a href="http://php.net/serialize">serialize</a>/<a href="http://php.net/unserialize">unserialize</a>.
</p>]]></description>
      <pubDate>Thu, 31 Jan 2013 11:31:01 -0600</pubDate>
    </item>
  </channel>
</rss>
