<?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>Sun, 12 Feb 2012 21:34:35 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Under the Hood of Yii's Component Architecture, Part 1]]></title>
      <guid>http://www.phpdeveloper.org/news/17472</guid>
      <link>http://www.phpdeveloper.org/news/17472</link>
      <description><![CDATA[<p>
On PHPMaster.com today <i>Steven O'Brien</i> takes a look at a popular PHP-based framework, <a href="http://www.yiiframework.com/">Yii</a> - specifically one of the components that makes it up, the <a href="http://www.yiiframework.com/doc/api/1.1/CComponent">CComponent</a> that provides a base for all other components in the framework.
</p>
<blockquote>
There's been a lot of buzz surrounding the use of frameworks for quite a while now and there are many great PHP frameworks to choose from. I was blown away by the simplicity and power of the base <a href="http://www.yiiframework.com/doc/api/1.1/CComponent">CComponent</a> class in the Yii framework. [...] Every class in the framework extends from the CComponent class, which means that all subclasses work as components and can raise and handle events as well as be reusable and configurable. This packs a lot of punch for such a little class!
</blockquote>
<p>
In this first post of the series, he looks at how this base class lets you work with class properties using the magic getters and setters. He includes some code showing how to set them up and how to use it to configure your object by passing in other component and their configuration.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 11:19:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Effects of Wrapping Code in Class Constructs]]></title>
      <guid>http://www.phpdeveloper.org/news/17320</guid>
      <link>http://www.phpdeveloper.org/news/17320</link>
      <description><![CDATA[<p>
DevShed has a new tutorial posted today looking to help you counteract the bad practice of <a href="http://www.devshed.com/c/a/PHP/PHP-Effects-of-Wrapping-Code-in-Class-Constructs/">wrapping procedural code in "class" constructs</a> and provide some useful suggestions of how to avoid it.
</p>
<blockquote>
Static helpers seem to be a great idea at first glance, as they're reusable components that don't require any kind of expensive instantiation for doing common tasks [...]. But the sad and unavoidable truth is in many cases they're simply wrappers for procedural code, which has been elegantly hidden behind a "class" construct. So what's wrong with this? Well, even in the most harmless situations, when you use a static helper that produces a deterministic output, you're actually throwing away the advantages that OOP provides.
</blockquote>
<p>
To illustrate, they create a basic validation class that can check for things like valid emails, float values, integers and URLs using PHP's <a href="http://php.net/filter_var">filter_var</a> function. They point out that the class is difficult to extend and that it is doing too many things to be correctly considered a "piece" of functionality. To correct the problem, they opt for a different approach - an abstract class acting as an interface to structure custom validators against. This provides set/get methods for things like the error message and value to evaluate. The implementation of the validators on top of this class is coming in the next part of the series.
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 10:06:58 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Building Concrete Validators]]></title>
      <guid>http://www.phpdeveloper.org/news/17293</guid>
      <link>http://www.phpdeveloper.org/news/17293</link>
      <description><![CDATA[<p>
On DevShed.com today there's the first part of a two-part series showing how to <a href="http://www.devshed.com/c/a/PHP/PHP-Building-Concrete-Validators/">build self-contained validator objects</a> that can be used to test the format of user input for validity.
</p>
<blockquote>
In this two-part tutorial, I show why the use of static helper classes can be detrimental to building robust and scalable object-oriented applications in PHP (though you should take into account that the concept is language agnostic). I also implement a set of instantiable, fine-grained validators, which can be easily tested in isolation, injected into the internals of other objects, and so forth.
</blockquote>
<p>
Their set of "concrete validators" are all based off of a validator interface/abstract class and check things like email formatting, floats, integers and URLs. Also included are a few examples of using the validators in a sample script.
</p>]]></description>
      <pubDate>Thu, 22 Dec 2011 11:24:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara's Blog: IteratorIterator - PHP Inconsistencies And WTFs]]></title>
      <guid>http://www.phpdeveloper.org/news/17071</guid>
      <link>http://www.phpdeveloper.org/news/17071</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has a new post to his blog sharing some <a href="http://blog.ircmaxell.com/2011/10/iteratoriterator-php-inconsistencies.html">inconsistencies with iterators</a> that he discovered as discussed with a <a href="http://twitter.com/#!/go_oh">fellow developer</a> - why some iterators only accept Iterator arguments and others don't.
</p>
<blockquote>
We were talking about why some of the SPL Iterators accept only an Iterator as the constructor argument (Such as <a href="http://us2.php.net/manual/en/class.limititerator.php">LimitIterator</a>), and others accept either an Iterator or an IteratorAggregate as the argument (Such as <a href="http://us2.php.net/manual/en/class.iteratoriterator.php">IteratorIterator</a>).  Feeling that this would be a useful feature to add (having all of them accept an IteratorAggregate), I opened up the PHP source and started looking at how hard of a change this would be.  What I found was... Interesting...
</blockquote>
<p>
He shares some of the C code he came across in his investigation including a "WTF" moment when he found a <a href="http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_iterators.c#1418">case statement for DIT_IteratorIterator</a> in a constructor. Because of some of the logic in this constructor, the inputted iterator is "cast down" to a class. This is shown in a few code examples comparing simple iteration objects and arrays and how it seems to be able to bypass class inheritance to use methods from other classes.
</p>]]></description>
      <pubDate>Tue, 01 Nov 2011 12:58:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[XpertDeveloper.com: Abstract in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17055</guid>
      <link>http://www.phpdeveloper.org/news/17055</link>
      <description><![CDATA[<p>
On the XpertDeveloper.com site today there's a new tutorial talking about something that can not only help the structure of your application but can make things more reusable in the end - <a href="http://www.xpertdeveloper.com/2011/10/abstract-in-php/">abstract classes</a>.
</p>
<blockquote>
For Abstact keyword we can say that, abstract is type of the class and class which we can't create a object of it. Surprised???? [...] Abstract class can be used some what like an interface in PHP. So basically we can implement class using abstract. We can't extend more than one abstract class while we can implement more than one interface.
</blockquote>
<p>
They introduce you to the creation of an abstract class and show how to set up some abstract methods inside. These methods are required to be defined as a part of the extension in your class. One of the benefits they don't mention of abstract classes over interfaces is the ability to have methods in the abstract that are actual code, not just definitions of the structure (that's more of what <a href="http://us.php.net/interfaces">interfaces</a> are for).
</p>]]></description>
      <pubDate>Fri, 28 Oct 2011 09:55:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ian Barber's Blog: Linear Regression in PHP (part 2)]]></title>
      <guid>http://www.phpdeveloper.org/news/17015</guid>
      <link>http://www.phpdeveloper.org/news/17015</link>
      <description><![CDATA[<p>
In <a href="http://phpdeveloper.org/news/16991">a previous post</a> <i>Ian Barber</i> started looking at code you could use to determine linear regression in PHP. In <a href="http://phpir.com/linear-regression-in-php-part-2">part two</a> he restructures the code into a more manageable class rather than the mostly procedural process it was before.
</p>
<blockquote>
In the <a href="http://phpir.com/linear-regression-in-php">last post</a> we had a simple stepping algorithm, and a gradient descent implementation, for fitting a line to a set of points with one variable and one 'outcome'. As I mentioned though, it's fairly straightforward to extend that to multiple variables, and even to curves, rather than just straight lines. For this example I've reorganised the code slightly into a <a href="https://github.com/ianbarber/PHPIR/blob/master/multivagraddec.php">class</a> to make life a little easier, but the main changes are just the hypothesis and learn functions.
</blockquote>
<p>
He restructures the learning method to make it easier to reuse and includes a "scale data" method to compensate for irregularities in the data and compute the variance.
</p>]]></description>
      <pubDate>Wed, 19 Oct 2011 12:40:16 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Script-Tutorials.com: How to Use APC Caching with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16860</guid>
      <link>http://www.phpdeveloper.org/news/16860</link>
      <description><![CDATA[<p>
On Script-Tutorials.com today there's a new article introducing you to <a href="http://www.script-tutorials.com/how-to-use-apc-caching-with-php/">using APC caching</a> in your PHP applications. Their simple example sets up a caching class that handles the dirty work for you.
</p>
<blockquote>
Today I have another interesting article for PHP. We will talking about caching, and practice of using caching in php. I will make review of APC caching and will show you how you can use APC in PHP. [...] Now people have learned to use the server memory for data storage. RAM much faster than hard disk, and the price of memory falls all the time, so let's use all these advantages of this.
</blockquote>
<p>
Included in the post is the code for a few different files - the caching class itself that implements the <a href="http://php.net/apc">APC</a> functions in PHP and some examples of it in use: saving objects, fetching data from the cache and removing things from the cache.
</p>]]></description>
      <pubDate>Thu, 15 Sep 2011 08:29:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[RubySource.com: PHP to Ruby: Modules, Mixins and Ducks]]></title>
      <guid>http://www.phpdeveloper.org/news/16722</guid>
      <link>http://www.phpdeveloper.org/news/16722</link>
      <description><![CDATA[<p>
In his latest article comparing some of the functionality of PHP to Ruby, <i>Dave Kennedy</i> looks at <a href="http://rubysource.com/php-to-ruby-modules-mixins-and-ducks/">modules, mixins and ducks</a> and how they compare to PHP's interfaces and abstract classes.
</p>
<blockquote>
If you have been writing PHP for a few years you will no doubt have come across Interfaces and Abstract classes. They were introduced in PHP5 object model and since have had medium usage in the PHP world. If you Google "PHP Interfaces" you will get some results on the official documentation and the rest saying how pointless they are. Why the divide? I believe it is mainly down to lack of understanding to what interfaces give you. They imply what your classes should do, but that's it. Yep, we are talking programming contracts.
</blockquote>
<p>
He starts with some code examples of an interface and a class that implements it (to work with PDFs). He makes an abstract class to extend the functionality even further and allow for different kinds of reporting PDFs to be generated. From there he moves into the Ruby world, showing examples of duck typing and modules to avoid duplication (mixins).
</p>]]></description>
      <pubDate>Tue, 16 Aug 2011 09:11:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Runtime Classes. A experiment with PHP and Object Oriented Programming]]></title>
      <guid>http://www.phpdeveloper.org/news/16684</guid>
      <link>http://www.phpdeveloper.org/news/16684</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has put together an experiment related to the current OOP structure of PHP - a test <a href="http://gonzalo123.wordpress.com/2011/08/08/runtime-classes-a-experiment-with-php-and-object-oriented-programming/">working with runtime classes</a>, a structure generated entirely when the script is executed and not predefined in the file.
</p>
<blockquote>
Last week I was thinking about creation of a new type of classes. PHP classes but created dynamically at run time. When this idea was running through my head I read the following <a href="http://dhotson.tumblr.com/post/1167021666/php-object-oriented-programming-reinvented">article</a> and I wanted to write something similar. Warning: Probably that it is something totally useless, but I wanted to create a working prototype (and it was fun to do it).
</blockquote>
<p>
His class is pretty basic - a "Human" object that echoes a "hello world" sort of message via a "hello()" method. He creates the classes inside of different test methods to ensure that his assertions are true. The tests check basic output of the "hello()" method, calling undefined methods, testing inheritance and a test creating and evaluating a dynamic function.
</p>
<p>
For something more complex, he creates a dynamic class that solves the <a href="http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz">FizzBuzz</a> kat, a popular programming puzzle. You can find the full code for this and his other examples <a href="https://github.com/gonzalo123/HClass">on github</a>.
</p>]]></description>
      <pubDate>Mon, 08 Aug 2011 09:17:05 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Philip Norton's Blog: PHPUnit Skeleton Classes]]></title>
      <guid>http://www.phpdeveloper.org/news/16626</guid>
      <link>http://www.phpdeveloper.org/news/16626</link>
      <description><![CDATA[<p>
In <a href="http://www.hashbangcode.com/blog/phpunit-skeleton-classes-588.html">this new post</a> to his blog, <i>Philip Norton</i> reminds you about a handy feature of <a href="http://phpunit.de">PHPUnit</a>, the popular PHP unit testing tool, that can make generating tests for your application simpler - the skeleton class generator.
</p>
<blockquote>
If you create classes in PHP then you should be unit testing them as much as you can. Setting up unit testing classes for your code can be time consuming and involve a bunch of copying and pasting. Thankfully, PHPUnit comes with a couple of helper functions that allow the creation of unit testing classes automatically, which can save a bit of copying and pasting.
</blockquote>
<p>
He includes an example of a class named "Spider" and shows both the contents of the class and the resulting test that comes from running "phpunit  --skeleton-test" on it. The resulting test has methods for each method in your class and marks them all as incomplete. As <i>Philip</i> notes, this is a good start but should never be relied upon as a test to leave as-is.
</p>]]></description>
      <pubDate>Mon, 25 Jul 2011 10:34:01 -0500</pubDate>
    </item>
  </channel>
</rss>

