<?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, 24 May 2012 20:09:18 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17953</guid>
      <link>http://www.phpdeveloper.org/news/17953</link>
      <description><![CDATA[<p>
In <a href="http://gonzalo123.wordpress.com/2012/05/14/building-a-simple-sql-wrapper-with-php/">this new post</a> to his blog <i>Gonzalo Ayuso</i> has shared a simple SQL wrapper that he uses to work with his databases. It takes in an injection of the database connection component (a href="http://php.net/pdo">PDO</a>) and provides functionality for inserts, updates, etc. with transaction support.
</p>
<blockquote>
If we don't use an ORM within our projects we need to write SQL statements by hand. I don't mind to write SQL. It's simple and descriptive but sometimes we like to use helpers to avoid write the same code again and again. Today we are going to create a simple library to help use to write simple SQL queries.
</blockquote>
<p>
It's a <a href="https://github.com/gonzalo123/sqlWrapper">lightweight library</a> that'd be good for basic uses, but when you start getting into something a bit more complex, something like <a href="http://www.doctrine-project.org/">Doctrine2</a> or <a href="http://www.propelorm.org/">Propel</a> might be a better solution (or whatever your framework of choice has built in).
</p>]]></description>
      <pubDate>Mon, 14 May 2012 10:17:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[GotoTech.com: Developer Diary: Taming Doctrine's 2000 Flushes]]></title>
      <guid>http://www.phpdeveloper.org/news/17897</guid>
      <link>http://www.phpdeveloper.org/news/17897</link>
      <description><![CDATA[<p>
In <a href="http://gototech.com/?p=221">this new post</a> to the GotoTech.com blog <i>Eric Burns</i> talks about a way he's "tamed Doctrine's 2000 flushes" with a wrapper around the EntityManager to make controlling the database flushes simpler.
</p>
<blockquote>
For my project I decided to use the Doctrine 2 ORM to manage my data layer. We also use this at work, so the biggest reason I chose this was to be able to learn more about Doctrine to help me in my job. But this decision also makes sense for my project because my entity relationships will likely be fairly straightforward for the most part and using an ORM will allow me to make a lot of progress very quickly without (I hope) causing me lots of trouble later on.
</blockquote>
<p>
His handy wrapper (Data Manager) makes it simpler to perform the flush and still take transactions into consideration. His simple class includes "flush", "commit" and "startTransaction" methods that don't actually perform the flush until the commit is called.
</p>]]></description>
      <pubDate>Wed, 02 May 2012 10:19:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Testing PHP scripts]]></title>
      <guid>http://www.phpdeveloper.org/news/17870</guid>
      <link>http://www.phpdeveloper.org/news/17870</link>
      <description><![CDATA[<p>
In <a href="http://css.dzone.com/articles/testing-php-scripts">this new post</a> to DZone.com, <i>Giorgio Sironi</i> talks about a method of testing that's non-invasive when you're in a chicken-and-egg kind of situation:
</p>
<blockquote>
The legacy code dilemma, however, is always present: you can't refactor the code before putting up some tests on it to avoid regressions and putting your application offline. At the same time, you can't easily unit test the code until some refactoring is introduced.
</blockquote>
<p>
He suggests making copies of some files to allow you to make small changes where needed to "mock" resources in the application to prevent it from accessing the actual data sources. His method fakes HTTP requests to the script and uses the copy of the script as an internal resource. Don't worry, code is included showing how its done - a basic "ForumPosting" class that includes the needed file and wraps the output in a buffer.
</p>]]></description>
      <pubDate>Thu, 26 Apr 2012 10:50:24 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: An Introduction to Services]]></title>
      <guid>http://www.phpdeveloper.org/news/17771</guid>
      <link>http://www.phpdeveloper.org/news/17771</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new article from <i>Alejandro Gervasio</i> introducing you to <a href="http://phpmaster.com/an-introduction-to-services/">the concept of "services"</a>, a layer put on top of your models to make a common API that's easier to reuse.
</p>
<blockquote>
Don't let the definition freak you out, as if you've been using MVC for a while the chances are you've used a service already. Controllers are often called services, as they carry out application logic and additionally are capable of interfacing to several client layers, namely views. Of course in a more demanding environment, plain controllers fail short in handling several clients without the aforementioned duplicating, so that's why the construction of a standalone layer is more suitable in such cases.
</blockquote>
<p>
He explains the process behind creating a simple domain model (<a href="http://cdn.phpmaster.com/files/2012/02/service_diagram.png">image here</a>)  and shows how the Service layer wraps it up into a simpler interface, leaving the model to handle the business logic. He uses the example of an "EncoderInterface" that's implemented in a "JsonEncoder" and "Serializer" to both provide a "setData" method. 
</p>]]></description>
      <pubDate>Tue, 03 Apr 2012 13:12:16 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Leaseweb Labs Blog: Migration to Symfony2 continued]]></title>
      <guid>http://www.phpdeveloper.org/news/17525</guid>
      <link>http://www.phpdeveloper.org/news/17525</link>
      <description><![CDATA[<p>
On the LeaseWeb Labs blog there's a continuation from a previous post about migrating your Symfony1 application over to Symfony2. In the <a href="http://phpdeveloper.org/news/17299">first part</a> of this series of posts, <i>Stefan Koopmanschap</i> talked about wrapping your code to make it work. In <a href="http://www.leaseweblabs.com/2012/02/migration-to-symfony2-continued/">this second post</a>, <i>Maurtis van der Schee</i> tackles two issues <i>Stefan</i> mentioned - performance problems and handling authorization/authentication.
</p>
<blockquote>
On December 21, 2011 Stefan Koopmanschap wrote an excellent article on this blog titled "Painless (well, less painful) migration to Symfony2." [...] We were very much inspired by his passionate elucidation and we were fully convinced of the urge to start migrating to Symfony2 as soon as possible. However, he also provided us with a "A word of caution" about 2 things: performance and authentication/authorization. This might get some people worried, but not us: it challenged us to find a solution for those two open issues.
</blockquote>
<p>
They explain why these two things are a problem and some of their solutions they've created - a .htaccess for routing and manually replicating the Symfony2 session in the Symfony1 code. Included in the post are the rewrite rules and code to make these two things happen (and a small configuration change to make them work).
</p>]]></description>
      <pubDate>Thu, 09 Feb 2012 11:51:59 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[VG Tech Blog: Unit Testing with Streams in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17229</guid>
      <link>http://www.phpdeveloper.org/news/17229</link>
      <description><![CDATA[<p>
On the VG Tech blog today there's a new post from <i>Andr&eacute; Roaldseth</i> about using <a href="http://phpunit.de">PHPUnit</a> to <a href="http://tech.vg.no/2011/06/27/unit-testing-with-streams-in-php/">test PHP streams</a>, basing the assertions on the data rather than the functionality itself.
</p>
<blockquote>
Using the memory/temporary stream provided by php:// stream wrapper you  can create a stream with read and write access directly to RAM or to a temporary file [using "php://memory"]. This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.
</blockquote>
<p>
There's no specific code examples here, but you can refer to the <a href="http://us3.php.net/manual/en/wrappers.php.php">stream wrappers</a> section of the PHP manual for more details on this and other handy built-in streams. Once created, it can then be used just as <a href="http://no.php.net/manual/en/book.stream.php">any other stream resource</a> can. This could be useful to provide mocks in your testing, replacing any other stream-able resource with a "memory" or "temp" placeholder.
</p>]]></description>
      <pubDate>Thu, 08 Dec 2011 09:13:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Microsoft Bing Translation PHP wrapper]]></title>
      <guid>http://www.phpdeveloper.org/news/16825</guid>
      <link>http://www.phpdeveloper.org/news/16825</link>
      <description><![CDATA[<p>
In a new post to his blog today <i>Sameer Borate</i> spotlights <a href="http://www.codediesel.com/php/microsoft-bing-translate-php-wrapper/">a translation wrapper for Bing</a> that lets you easily use their API to translate text or determine what language the given text is in.
</p>
<blockquote>
Microsoft Language translation is an interesting service. Not only can you do language translation, you can also detect the language of a particular text. The given class provides a PHP wrapper which will help developers translate text from one language to another in a easy manner. The library also supports caching, helping you keep your translations fast and simple.
</blockquote>
<p>
<a href="http://www.codediesel.com/downloads/bing-php">His translation library</a> requires an <a href="http://www.bing.com/developers/createapp.aspx">AppId</a> for configuration and cURL to handle the messaging back and forth. Translation is as easy as calling "translate()" on a string, language fetching with "LanguageNames()" and even converting the text to speech with the "speak()" method.
</p>]]></description>
      <pubDate>Wed, 07 Sep 2011 09:43:25 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Using a stream wrapper to access CouchDb attachments with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16264</guid>
      <link>http://www.phpdeveloper.org/news/16264</link>
      <description><![CDATA[<p>
On DZone.com today there's a new post from <i>Gonzalo Ayuso</i> about using a stream wrapper to <a href="http://css.dzone.com/news/using-stream-wrapper-access">access CouchDb database</a> directly from PHP (via a call to its local file).
</p>
<blockquote>
Thanks to a <a href="http://gonzalo123.wordpress.com/2010/09/01/using-monkey-patching-to-store-files-into-couchdb-using-the-standard-filesystem-functions-with-php/#comment-377">comment</a> in my last post (many thanks <a href="http://www.whitewashing.de/">Benjamin</a>) I've discovered that it's possible to create a stream wrapper in <a href="http://www.php.net/manual/en/stream.streamwrapper.example-1.php">PHP</a> (I thought it was only available with a C extension). It's pretty straightforward to create the wrapper. Of course it's only an approach. We can create more functionality to our stram wrapper but at least this example meets my needs.
</blockquote>
<p>
His wrapper uses a client from his <a href="http://code.google.com/p/nov-framework/">Nov</a> framework to open the stream to the given path and gives read and write methods to work with the data inside the database. Code for the wrapper class is included as well as a bit of example code showing how it can be used with the custom stream protocol. You can find the complete code <a href="http://code.google.com/p/nov-framework/">here</a>.
</p>]]></description>
      <pubDate>Thu, 28 Apr 2011 10:45:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[3 Engineers Blog: 3 Step Layouts in Zend Framework]]></title>
      <guid>http://www.phpdeveloper.org/news/16144</guid>
      <link>http://www.phpdeveloper.org/news/16144</link>
      <description><![CDATA[<p>
In a recent post to the 3 Engineers blog, they take the usual "Two Step" approach the Zend Framework takes to generating view data (Zend_View + Zend_Layout) and takes it up one more step by using <a href="http://3engineers.clariondoor.com/creating-3-step-layouts-with-zendlayout">Three Step Layouts with a simple wrapper</a>.
</p>
<blockquote>
While the Two Step View pattern creates a reasonable paradigm for seperating layout presentation from page presentation, enabling Three-level Inheritance allows for even better separation. In other words, using 3 Step Layouts is a possible and often necessary investment to make when implementing front-ends in Zend Framework projects; they allow fine grain re-usability that provides for a DRYer presentation layer.
</blockquote>
<p>
They have a three step process you can follow (complete with code snippets) that'll have you working with their 3 layers easily. The wrapper is a sort of "boostrap" for the layout. The nested layout is then pulled into this wrapper (for example's sake, theirs is called "default") and then the view can be served as normal and placed into the content location. There's also a bit of code showing how to switch out the layout if there's ever a need - like different layouts for the admin, user and main parts of your application.
</p>]]></description>
      <pubDate>Mon, 04 Apr 2011 13:04:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Cal Evans' Blog: PHP Wrapper for Klout API]]></title>
      <guid>http://www.phpdeveloper.org/news/15830</guid>
      <link>http://www.phpdeveloper.org/news/15830</link>
      <description><![CDATA[<p>
In a new post to his blog today <i>Cal Evans</i> mentions a <a href="http://blog.calevans.com/2011/01/31/php-wrapper-for-klout-api/">new API wrapper he's developed</a> to work with the <a href="http://klout.com/">Klout</a> website (a site showing your "clout" on twitter).
</p>
<blockquote>
In a previous tweet about <a href="http://blog.calevans.com/2011/01/25/accessing-twitter-via-zend_service_twitter/">playing with Klout and Twitter</a> I talked about a project I am working on that mines Klout for interesting people. (Well, interesting to me) The main body of code remains procedural because...well because it works and it's not something I'm going to share so why bother cleaning it up. However parts of it may be useful to me in other projects. So I abstracted the Klout API into a class and have posted it for anyone who wants to use it.
</blockquote>
<p>
His <a href="https://github.com/calevans/Klout-API-Wrapper-for-PHP">Klout wrapper for PHP</a> (a github project) is largely procedural but gives you a good idea of how to talk to their API. <i>Cal</i> mentions some other things he's wanting to do with the script, but notes that it's ready for use now without any other changes. You can find out more about Klout on <a href="http://klout.com/">their website</a>.
</p>]]></description>
      <pubDate>Mon, 31 Jan 2011 10:51:23 -0600</pubDate>
    </item>
  </channel>
</rss>

