<?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, 26 May 2013 01:36:36 -0500</pubDate>
    <ttl>30</ttl>
    <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[Chris Jones: Getting Started with PHP Zend Framework 2 for Oracle DB]]></title>
      <guid>http://www.phpdeveloper.org/news/19588</guid>
      <link>http://www.phpdeveloper.org/news/19588</link>
      <description><![CDATA[<p>
In his <a href="https://blogs.oracle.com/opal/entry/getting_started_with_php_zend">latest post</a> to his site <i>Chris Jones</i> shows you how to update the <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html">Zend Framework 2 tutorial app</a> (quickstart) to make it work with an Oracle database instead.
</p>
<blockquote>
This post shows the changes to the <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html">ZF2 tutorial application</a> to allow it to run with Oracle Database 11gR2. [...] The instructions for creating the sample ZF2 application are <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html">here</a>. Follow those steps as written, making the substitutions shown [in the rest of the post].
</blockquote>
<p>
The full schema definition is included in the post, complete with the same sample data as the tutorial. He includes the updates you'll need to make to the database configuration for the OCI8 connection and changes to the code to accommodate the Oracle data format (mostly uppercasing everything). 
</p>
Link: https://blogs.oracle.com/opal/entry/getting_started_with_php_zend]]></description>
      <pubDate>Wed, 15 May 2013 10:55:41 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Christopher Martinez: Static code analysis tools for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19563</guid>
      <link>http://www.phpdeveloper.org/news/19563</link>
      <description><![CDATA[<p>
<I>Christopher Martinez</i> has a recent post to his site that covers some of the <a href="http://chrsm.org/2013/05/05/code-analysis-tools-for-php">static analysis tools available for PHP</a> including the PHP Mess Detector, PHP CodeSniffer and the PHP Analyzer.
</p>
<blockquote>
I believe in writing code that is easy to understand, easy to test, and easy to refactor. Yes, I realize that the statement above is pretty general and open to interpretation. Not everyone needs external tools to ensure quality in their code...but, I work on things from time to time that have absolutely no tests. [...] For whatever reason, this happens a lot more frequently in the PHP world. I'm guilty of not writing tests and checking how I write code, sometimes, too. Things are bright, though, for the PHP community - for quite some time now, we've had fantastic tools that assist us in writing better code. 
</blockquote>
<p>
He covers each of the tools, talks some about what they're good for and gives examples of their use, including output. He also talks some about the <a href="https://github.com/facebook/pfff">Pfff</a> set of tools created by Facebook. He also talks some about how these tools fit into his daily work as a part of his pre-commit hooks in git.
</p>
Link: http://chrsm.org/2013/05/05/code-analysis-tools-for-php]]></description>
      <pubDate>Wed, 08 May 2013 12:38:22 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Elijah Horton: Sandboxing Untrusted Code With PHPSandbox]]></title>
      <guid>http://www.phpdeveloper.org/news/19520</guid>
      <link>http://www.phpdeveloper.org/news/19520</link>
      <description><![CDATA[<p>
<i>Elijah Horton</i> has a recent post to his site sharing a tool he's developed to <a href="http://www.fieryprophet.com/blog/detail/sandboxing-untrusted-code-with-phpsandbox">sandbox and validate PHP code</a> of user-contributed code.
</p>
<blockquote>
Few quotes related to the PHP language are as pithy and resoundingly accurate as the phrase: "Eval is evil." The reasons are myriad: the eval() function basically gives whatever code is passed to it unlimited control of the parser, and this freedom makes eval() both a temptation for developers, who may need to dynamically control PHP at runtime, and a panacea for hackers who are ever-searching for more servers to add to their botnets. So, how does one make use of the extreme power available through runtime evaulation of PHP, without exposing one's server to near-certain rooting? Through a sandbox. 
</blockquote>
<p>
His tool - <a href="https://github.com/fieryprophet/php-sandbox">PHPSandbox</a>, uses the <a href="https://github.com/nikic/PHP-Parser">PHP-Parser</a> library to deconstruct the PHP code its given and look for issues. He gives an example of a call to <a href="http://php.net/mail">mail</a> and how it would catch the issue. He shows how to install it via Composer, how to configure it with whitelisted methods/functions. It also includes a way to overwrite function calls with a bit safer alternative.
</p>
Link: http://www.fieryprophet.com/blog/detail/sandboxing-untrusted-code-with-phpsandbox]]></description>
      <pubDate>Mon, 29 Apr 2013 11:56:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Benjamin Eberlei: Traits are Static Access]]></title>
      <guid>http://www.phpdeveloper.org/news/19453</guid>
      <link>http://www.phpdeveloper.org/news/19453</link>
      <description><![CDATA[<p>
In a new post to his site <i>Benjamin Eberlei</i> shares an opinion about traits, noting that they're <a href="http://www.whitewashing.de/2013/04/12/traits_are_static_access.html">basically the same as static functionality</a> when it comes to several things like coupling, not being testable and being a "global state" container.
</p>
<blockquote>
I used to look forward to traits as a feature in PHP 5.4, but after discussions with Kore I came to the conclusion that traits are nothing else than static access in disguise. They actually lead to the exact same code smells. Familiar with the outcome of too much static use, we should reject traits as just another way of statically coupling your code to other classes.
</blockquote>
<p>
He includes some code examples showing traits in use in an example controller to handle a simple redirect. He points out at least six different issues with just this simple implementation. He rewrites it as "static" code to help prove his point. He comes to the conclusion that, much like static methods, traits should be avoided and instead aggregation should be favored.
</p>
Link: http://www.whitewashing.de/2013/04/12/traits_are_static_access.html]]></description>
      <pubDate>Fri, 12 Apr 2013 11:16:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Andrew Podner: Make it Testable-No Matter how Painful it is]]></title>
      <guid>http://www.phpdeveloper.org/news/19409</guid>
      <link>http://www.phpdeveloper.org/news/19409</link>
      <description><![CDATA[<p>
In a new post <i>Andrew Podner</i> recommends that, as you're doing your day to day development, you try your hardest to <a href="http://unassumingphp.com/make-it-testable-no-matter-how-painful-it-is/">create testable code</a>, no matter how painful it is.
</p>
<blockquote>
I look at the situation we have gotten into by having this problem [of replacing a large legacy application], and frankly, it is like the tech version of 'Scared Straight'.  The paranoia of such a far reaching application within the enterprise that absolutely has to deploy successfully and also be very flexible to meet the needs of the future have driven me to the point of near madness in trying to make sure this thing is bulletproof, enter Test Driven Development.
</blockquote>
<p>
He includes an example situation he recently was faced with in his code...and opted for the "easy" way out (difficult to test). He talks some about the issues, dependencies and coupled code this has created. He does, however, show a solution to the issue - passing in the dependencies as they're needed, not defining them in the method.
</p>
<blockquote>
For me, writing custom apps in an enterprise environment is not about rapid deployment and looking like a hero.  It is about deploying software with a design life of 7-10 years, because the change management involved in deployment is not something you want be be doing over and over again.  Testable code with 100% coverage of unit tests, well developed integration testing, and prolific use of tools like PHPUnit & Selenium are part of the development culture because while speed is important, durability is even more critical to business. 
</blockquote>
Link: http://unassumingphp.com/make-it-testable-no-matter-how-painful-it-is/]]></description>
      <pubDate>Thu, 04 Apr 2013 09:39:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[QaFoo.com: Code Coverage with Behat]]></title>
      <guid>http://www.phpdeveloper.org/news/19406</guid>
      <link>http://www.phpdeveloper.org/news/19406</link>
      <description><![CDATA[<p>
On the QaFoo blog today there's a post for those using the <a href="http://behat.org/">Behat</a> testing tool showing a way to <a href="http://qafoo.com/blog/040_code_coverage_with_behat.html">collect code coverage metrics</a> based on your tests using the <a href="https://github.com/sebastianbergmann/php-code-coverage">PHP_CodeCoverage</a> library and <a href="https://github.com/sebastianbergmann/phpcov">phpcov</a>.
</p>
<blockquote>
There is generally no point in having code coverage for Behat test cases because of their nature: The purpose of an acceptance test is to assert a certain behavior of an application, not to technically test a piece of code. Therefore, there is no point in checking for uncovered code pieces in order to write a Behat test for it. That said, there is still a scenario where you want to peek at code coverage of Behat tests: When creating them as wide-coverage tests before starting to refactor legacy code. Behat in combination with Mink provides you with a great tool for such tests.
</blockquote>
<p>
They help you get the tools installed and show the code you'll need to add to the application itself to collect the coverage data as the tests execute. It keys off of a file existing/not existing to know if it should execute the coverage or not. The <a href="https://github.com/sebastianbergmann/phpcov">phpcov</a> tool can then be used to generate the HTML output of the coverage information for easy viewing.
</p>
Link: http://qafoo.com/blog/040_code_coverage_with_behat.html]]></description>
      <pubDate>Wed, 03 Apr 2013 12:37:30 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Bob Majdak: Extending an Iterator to use an Iterator to make your code a little cleaner]]></title>
      <guid>http://www.phpdeveloper.org/news/19300</guid>
      <link>http://www.phpdeveloper.org/news/19300</link>
      <description><![CDATA[<p>
In <a href="http://catch404.net/2013/03/extending-an-iterator-to-use-an-iterator-to-make-your-code-a-little-cleaner/">this new post</a> to his site <i>Bob Majdak</i> talks about extending iterators to help make it easier to customize it for your needs.
</p>
<blockquote>
One of the nice things about iterators is the ability to shove them into other iterators, allowing you to wrap their functionality in other functionality to return a more precise result set. Take for example the idea that we want to read a directory to list only the images inside of it. There are two main ways to do this, via <a href="http://www.php.net/opendir>opendir</a> / <a href="http://www.php.net/readdir">readdir</a> functions and via <a href="http://www.php.net/FilesystemIterator">FilesystemIterator</a> objects. Going the FilesystemIterator route, one common way seems to be extend another class called <a href="http://www.php.net/FilterIterator">FilterIterator</a> which allows you to customize a filter based on you overwriting a method called accept().
</blockquote>
<p>
He shows not only overriding the "accept" method, but also the constructor to make using this new iterator a much simpler (and cleaner) call. You can find out more about the FilesystemIterator (and others) over in <a href="http://www.php.net/manual/en/spl.iterators.php">the Iterators section</a> of the PHP manual.
</p>]]></description>
      <pubDate>Tue, 12 Mar 2013 09:25:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Greg Freeman: How to Tell if Your PHP Site has been Hacked or Compromised]]></title>
      <guid>http://www.phpdeveloper.org/news/19273</guid>
      <link>http://www.phpdeveloper.org/news/19273</link>
      <description><![CDATA[<p>
In <a href="http://www.gregfreeman.org/2013/how-to-tell-if-your-php-site-has-been-compromised/">this recent post</a> to his site <i>Greg Freeman</i> share some things to check for when you think your PHP site (any kind, even something like WordPress) might have been compromised.
</p>
<blockquote>
A friend of mine recently had their site compromised, they were running an older version of IP.Board that is vulnerable to a local file inclusion vulnerability. This post won't be about IP.Board or any specific php code, it will show you how to locate potential malicious php code hosted on your servers and how to fix it. Finally I will give a brief explanation on what attacker's are uploading to compromised sites.
</blockquote>
<p>Among the things he recommends are tips like:</p>
<ul>
<li>Check your Access Logs
<li>Finding Recently Modified PHP Files
<li>Finding obfuscated code 
<li>Always search your writable upload directories for executable code
<li>Check .htaccess Files if you use Apache
</ul>
<p>
You can find the descriptions for each of these (and some others to watch out for) in <a href="http://www.gregfreeman.org/2013/how-to-tell-if-your-php-site-has-been-compromised/">the full post</a>.
</p>]]></description>
      <pubDate>Tue, 05 Mar 2013 12:54:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: How to Write Code That Embraces Change]]></title>
      <guid>http://www.phpdeveloper.org/news/19132</guid>
      <link>http://www.phpdeveloper.org/news/19132</link>
      <description><![CDATA[<p>
On NetTuts.com today there's a great new article about how to <a href="http://net.tutsplus.com/tutorials/how-to-write-code-that-embraces-change/">write code that embraces change</a> and can be easily updated and reconfigured due to a decoupled nature and use of good OOP concepts.
</p>
<blockquote>
Writing code, which is easy to change is the Holy Grail of programming. Welcome to programming nirvana! But things are much more difficult in reality: source code is difficult to understand, dependencies point in countless directions, coupling is annoying, and you soon feel the heat of programming hell. In this tutorial, we will discuss a few principles, techniques and ideas that will help you write code that is easy to change.
</blockquote>
<p>
He covers some of the good OOP principles to think about when developing - like cohesion, orthogonality and coupling (via class methods, polymorphism, dependency injection or interfaces). He spends some time looking at the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> development principles and how you can implement each of them in some sample code. He also talks some about high level design and how the separation of concerns can help make your code easier to maintain and change.
</p>]]></description>
      <pubDate>Mon, 04 Feb 2013 13:18:58 -0600</pubDate>
    </item>
  </channel>
</rss>
