<?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 20:14:05 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: How to protect from SQL Injection with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17514</guid>
      <link>http://www.phpdeveloper.org/news/17514</link>
      <description><![CDATA[<p>
In a recent post to his blog, <i>Gonzalo Ayuso</i> shares a few tips on <a href="http://gonzalo123.wordpress.com/2012/02/06/how-to-protect-from-sql-injection-with-php/">preventing SQL injection</a> attacks on your applications.
</p>
<blockquote>
Security is a part of our work as developers. We need to ensure our applications against malicious attacks. SQL Injection is one of the most common possible attacks. Basically SQL Injection is one kind of attack that happens when someone injects SQL statements in our application. You can find a lot of info about SQL Injection attack. Basically you need to follow the security golden rule: "Filter input, Escape output".
</blockquote>
<p>
He advocates the use of the PDO abstraction layer to filter out a lot of the issues. Using its prepared statements, you can easily strip out things that just adding slashes to user input wouldn't prevent. He also includes a reminder about database permissions - allowing only certain users the ability to, for example, delete can help provide one more level of security (in other words, don't use a "super user" in production).
</p>]]></description>
      <pubDate>Wed, 08 Feb 2012 08:07:05 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Charles Sprayberry's Blog: DI and global state]]></title>
      <guid>http://www.phpdeveloper.org/news/17470</guid>
      <link>http://www.phpdeveloper.org/news/17470</link>
      <description><![CDATA[<p>
In response to some of the comments made on his <a href="http://phpdeveloper.org/news/17457">previous post</a> about why you should use dependency injection in your applications, <i>Charles Sprayberry</i> is <a href="http://cspray.github.com/2012/01/29/DI-and-global-state.html">back with some more concrete examples</a> showing how it all works with some code to back it up.
</p>
<blockquote>
To help better explain each of the three aspects of DI I discussed in the previous article I'll be going over each more thoroughly and with those code examples requested. I'll be going through each point one at a time as the explanations will likely be of some length compared to the original post.
</blockquote>
<p>
He starts with the "villain" of the story - the Singleton design pattern, a difficult to test method that lulls you into thinking you're not in the global scope. He talks about the problem of using this approach and how the <a href="http://sourcemaking.com/design_patterns/factory_method">Factory</a> design pattern can be used to create an alternative. He changes up the example to create a "DbTableFactory" class that can be used to create the objects needed - in this case a "UserTable" object with the connection injected into it at construct time.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 09:24:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Marcelo Gornstein's Blog: Writing PHP applications with Doctrine2 as ORM and Ding as DI container]]></title>
      <guid>http://www.phpdeveloper.org/news/17469</guid>
      <link>http://www.phpdeveloper.org/news/17469</link>
      <description><![CDATA[<p>
In a recent post <i>Marcelo Gornstein</i> takes a look at <a href="http://marcelog.github.com/articles/php_applications_with_doctrine2_orm_and_ding_di_container.html">using dependency injection with Doctrine2</a> using his <a href="http://marcelog.github.com/Ding">Ding</a> container.
</p>
<blockquote>
This article will show how we can develop software in php with a nifty design and architecture, and very much like other languages like java, using an ORM and an AOP, DI, Events container. I will assume you've read (or at least took a quick look) at <a href="http://marcelog.github.com/articles/creating_php_cli_standalone_portable_applications_with_pear_dependencies.html">this article</a> that explains the tree layout used throughout the code, and that you have some basic knowledge of <a href="http://www.doctrine-project.org/">Doctrine2</a> and used it before on your own.
</blockquote>
<p>
He starts with the result - an easy to use, self-contained (and decoupled) system for accessing the Doctrine2 instance. It's event-driven and uses <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a> to mange interactions between components (or as he calls them "beans"). Code is included for the entire process for a logger, the User entity, entity manager, user repository and transactional aspect. You can find the complete source for his example <a href="https://github.com/marcelog/Doctrine2-Ding-Example">on his github account</a>.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 08:59:18 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Charles Sprayberry's Blog: Why you should use DI]]></title>
      <guid>http://www.phpdeveloper.org/news/17457</guid>
      <link>http://www.phpdeveloper.org/news/17457</link>
      <description><![CDATA[<p>
In <a href="http://cspray.github.com/2012/01/24/why-you-should-use-DI.html">this recent post</a> from <i>Charles Sprayberry</i> he explains why using dependency injection (DI) in your application is a good idea and can help make things easier in the long run.
</p>
<blockquote>
Dependency Injection is just a fancy term for passing dependencies to the object needing them instead of letting the object create its own. Hopefully, you've watched this <a href="http://googledata.org/google-testing/clean-code-talks-dependency-injection/">great Google Clean Code talk about dependency injection</a> by <a href="http://misko.hevery.com/">Misko Hevery</a> where he talks about why you should ask for things instead of looking for them. I'm gonna talk about some reasons to use DI beyond just those presented in the video. 
</blockquote>
<p>He breaks it up into a few different sections:</p>
<ul>
<li>It helps in the battle against global state
<li>It helps your design
<li>It makes using the single responsibility principle easier
</ul>]]></description>
      <pubDate>Fri, 27 Jan 2012 10:18:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 12)]]></title>
      <guid>http://www.phpdeveloper.org/news/17445</guid>
      <link>http://www.phpdeveloper.org/news/17445</link>
      <description><![CDATA[<p>
In <a href="http://fabien.potencier.org/article/62/create-your-own-framework-on-top-of-the-symfony2-components-part-12">this final post</a> of his series about building a framework on Symfony2 components, <i>Fabien Potencier</i> focuses again on flexibility - allowing you to have more than one front controller with different configurations thanks to dependency injections.
</p>
<blockquote>
Does it means that we have to make a choice between flexibility, customization, ease of testing and not having to copy and paste the same code into each application front controller? As you might expect, there is a solution. We can solve all these issues and some more by using the Symfony2 dependency injection container.
</blockquote>
<p>
The Symfony2 DIC (DependencyInjection) allows you to create a container with the objects and settings that you want and inject that into the main "Framework" class for its use. He registers most of the components he's added over the series like the UrlMatcher, RouterListener, ExceptionListener, EventDispatcher and the Framework class itself. This is all stored in a separate file(s) and can be conditionally included based on your environment. He shows how to register a custom listener, add parameters to the DIC configuration.
</p>]]></description>
      <pubDate>Wed, 25 Jan 2012 08:36:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Service Layers in PHP Applications (a Series)]]></title>
      <guid>http://www.phpdeveloper.org/news/17004</guid>
      <link>http://www.phpdeveloper.org/news/17004</link>
      <description><![CDATA[<p>
DevShed has posted a series of tutorials talking about different sorts of service layers in PHP applications - seven of them to be exact:
</p>
<blockquote>
If you're looking for an approachable guide that teaches you how to implement an easily-customizable service layer in PHP, then take a peek at this article series. In a step-by-step fashion, it walks you through the development of a sample web application, which uses a service to perform CRUD operations on a domain model composed of a few user entities.
</blockquote>
<p>Service layer types covered in the series are:</p>
<ul>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-A-Final-Example/">Working with database entities</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Services-Layers-Data-Mappers/">Data Mappers</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Database-Adapters/">Database adapters</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Handling-Entity-Collections/">Handling Entity Collections</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-User-Services/">User Services</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Dependency-Injection/">Dependency Injections</a>
<li><a href="http://www.devshed.com/c/a/PHP/PHP-Service-Layers-Modeling-Domain-Objects/">Modeling Domain Objects</a>
</ul>]]></description>
      <pubDate>Tue, 18 Oct 2011 08:50:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: Zend Framework 2.0: Dependency Injection (Part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/16953</guid>
      <link>http://www.phpdeveloper.org/news/16953</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Padraic Brady</i> takes a look at <a href="http://blog.astrumfutura.com/2011/10/zend-framework-2-0-dependency-injection-part-1/">dependency injection in Zend Framework 2.0</a>. In this first part, however, he introduces the concept of "dependency injection" and offers a few suggestions on its use and tools that can make it simpler.
</p>
<blockquote>
If you've been watching the PHP weather vane (we call it Twitter for short), you may have noticed a shift in Symfony and Zend Framework. Version 2.0 of both web application frameworks feature Dependency Injection Containers (DICs) as the primary means of creating the objects (and even Controllers) your application will use. This is an interesting shift in a programming language that often stubbornly evaded adopting DICs to any great extent. 
</blockquote>
<p>
He introduces dependency injection (DI) as a method for "injecting" objects and configurations into other interfaces without any specific kind of relation between the two. Part of several DI implementations is a container that does some of the magic object creation for you. He applies this concept to a Zend Framework structure and talks briefly about why these containers are "the devil" because they (usually) add complexity where none is needed. He points out one container library, <a href="http://pimple.sensiolabs.org/">Pimple</a>, that gets it right in his opinion - defining object creation as closures. In the next part of the series, he'll compare the Zend Framework's DI setup against Pimple (and Symfony's) implementations.
</p>]]></description>
      <pubDate>Wed, 05 Oct 2011 12:34:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Wojciech Sznapka's Blog: Loosening dependencies with closures in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16911</guid>
      <link>http://www.phpdeveloper.org/news/16911</link>
      <description><![CDATA[<p>
<i>Wojciech Sznapka</i> has a new tutorial posted to his blog today looking at removing some of the issues surrounding dependencies in PHP applications <a href="http://blog.sznapka.pl/loosening-dependencies-with-closures-in-php">with the help of closures</a>.
</p>
<blockquote>
Today I ran into a little issue: how to pass generic logger object to method? I wanted to get some verbose output from method, which I call from Command, but onc time it should log with Symfony2 OutputInterface and other time it should use monolog logger. Of course I can make some wrapper class for both of them, but it would be kind of an overkill. The Closure from PHP 5.3 came with solution.
</blockquote>
<p>
His alternative creates a closure for his Symfony2 application that defines the logger handling in an abstract way and injects that object into his job queue manager for handling. This way the manager doesn't have to worry about handing the mailing itself, it's just deferred to the mailing object. You can find out more about this technique, dependency injection, <a href="http://en.wikipedia.org/wiki/Dependency_injection">here</a>.
</p>]]></description>
      <pubDate>Tue, 27 Sep 2011 08:22:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jakub Zalas' Blog: Managing object creation in PHP with the Symfony2 Dependency Injection component]]></title>
      <guid>http://www.phpdeveloper.org/news/16832</guid>
      <link>http://www.phpdeveloper.org/news/16832</link>
      <description><![CDATA[<p>
On his blog today <i>Jakub Zalas</i> has posted a tutorial he's written up about <a href="http://www.zalas.eu/managing-object-creation-in-php-with-the-symfony2-dependency-injection-component">using dependency injection in PHP</a> with the Symfony2 dependency injection component (DIC).
</p>
<blockquote>
Symfony's <a href="https://github.com/symfony/DependencyInjection">DependencyInjection component</a> is a PHP implementation of a Service Container, or as others like to call it, a Dependency Injection Container (DIC). The component also provides useful tools for handling service definitions, like XML loaders or dumpers. If you want to learn more about the dependency injection or the dependency injection container, read an excellent series of articles on the subject by Fabien Potencier: <a href="http://fabien.potencier.org/article/11/what-is-dependency-injection">What is Dependency Injection?</a>
</blockquote>
<p>
He walks you through the entire process - installing the needed libraries (the DIC, a config and class loader component and Buzz, a lightweight HTTP client). Code is included to show object creation the "usual way" and then creating the same types of objects in a dependency injection environment. Also included is a sample XML document describing the services for the container. He finishes the post with a <a href="http://www.zalas.eu/uploads/wp/2011/08/services.png">GraphvizDumper-generated image</a> for the container.
</p>]]></description>
      <pubDate>Thu, 08 Sep 2011 09:24:55 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Srdjan Vranac's Blog: Custom Repository with DIC in Symfony2]]></title>
      <guid>http://www.phpdeveloper.org/news/16770</guid>
      <link>http://www.phpdeveloper.org/news/16770</link>
      <description><![CDATA[<p>
<i>Srdjan Vranac</i> has a new post to his blog showing you how to <a href="http://blog.code4hire.com/2011/08/custom-repository-with-dic-in-symfony2/">create a custom repository</a> with the dependency injection features that already come with the Symfony2 framework.
</p>
<blockquote>
I am currently working on some Symfony2 bundles, I needed a custom repository to house hold my custom queries, that part is easy with sf2, and quite nicely explained in the <a href="http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes">Manual</a>.
</blockquote>
<p>
He walks you through the setup of a simple custom repository (a part of a Code4Hire bundle) and a (less elegant) call that can be used to reference it and its methods. To make things a big more clean and take advantage of the full dependency injection features of the framework, he makes a change to move the repository into the services.xml. This defines the container and makes it available to the application directly in function calls (like his render() example near the end of the post).
</p>]]></description>
      <pubDate>Thu, 25 Aug 2011 09:02:00 -0500</pubDate>
    </item>
  </channel>
</rss>

