<?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>Fri, 24 May 2013 15:28:43 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[MaltBlue.com: Zend Framework 2 Core Concepts - Dependency Injection]]></title>
      <guid>http://www.phpdeveloper.org/news/18902</guid>
      <link>http://www.phpdeveloper.org/news/18902</link>
      <description><![CDATA[<p>
In <a href="http://www.maltblue.com/articles-2/zend-framework-2-core-concepts-understanding-dependency-injection">this new post</a> <i>Matthew Setter</i> has posted about one of the core concepts behind the structure and use of Zend Framework 2, its use of dependency injection to handy object relationships and access (via Zend/Di).
</p>
<blockquote>
As Zend Framework 2 is well and truly here, before some of us who are new to it dive right on in, whether you're completely new or, like me, migrating from Zend Framework 1, it's really important to ensure that we understand the core concepts on which it's based. [...] In this, the first part in the series, I'm going to go through what dependency injection (DI) is. However, as there are a number of great posts already available on the topic by some very experienced developers, [...] I'm not going to rehash them.
</blockquote>
<p>
Instead he extracts out useful tips from posts of a few other sources on ZF2 and dependency injection in general: <a href="http://mwop.net/blog/260-Dependency-Injection-An-analogy.html">Matthew Weier O'Phinny</a>, the <a href="http://framework.zend.com/manual/2.0/en/modules/zend.di.introduction.html">ZF2 manual</a>, <i>Martin Fowler</i> on <a href="http://martinfowler.com/articles/injection.html"> dependency injection</a>, <a href="http://en.wikipedia.org/wiki/Dependency_injection">Wikipedia</a> and more. He also includes lots of links to more great articles on the subject, both ZF2-specific and for DI iin general.
</p>]]></description>
      <pubDate>Mon, 17 Dec 2012 10:09:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell: 9 Magic Methods in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18875</guid>
      <link>http://www.phpdeveloper.org/news/18875</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a new post showing <a href="http://www.lornajane.net/posts/2012/9-magic-methods-in-php">nine of the magic methods</a> that are included in PHP by default (like __construct, __get and __set) including a few you may not have used before.
</p>
<blockquote>
The <A href="http://php.net/manual/en/language.oop5.magic.php">"magic" methods</a> are ones with special names, starting with two underscores, which denote methods which will be triggered in response to particular PHP events. That might sound slightly automagical but actually it's pretty straightforward, we already saw an example of this in the last post, where we used a constructor - so we'll use this as our first example.
</blockquote>
<p>She includes details (and some code samples) for these methods:</p>
<ul>
<li>__construct
<li>__destruct
<li>__get
<li>__set
<li>__call
<li>__sleep
<li>__wakeup
<li>__clone
<li>__toString
</ul>
<p>
You can find out about these and a few others in <a href="http://php.net/manual/en/language.oop5.magic.php">this page</a> of the PHP manual.
</p>]]></description>
      <pubDate>Tue, 11 Dec 2012 12:18:49 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Maclean: Why one-line installers are a bad idea]]></title>
      <guid>http://www.phpdeveloper.org/news/18505</guid>
      <link>http://www.phpdeveloper.org/news/18505</link>
      <description><![CDATA[<p>
There's a feature that's usage has been showing up more and more in software projects (both open source and not) that allows you to install their system with a single line command, usually involving curl and maybe piping it to a shell. In <a href="http://mgdm.net/weblog/why-one-line-installers-are-bad/">this recent post</a> <i>Michael Maclean</i> takes a look at this trend and some of the possible pitfalls of the approach.
</p>
<blockquote>
There has been a trend in the last while for various bits of useful software to have a one-line shell command recommended as the installation method. The usual form of this is to pipe something like curl or wget to some interpreter, be it bash, php, ruby, or some such. [...] This [type of] command takes the output of curl and pipes it straight to bash. I have several issues with this.
</blockquote>
<p>
His three main points center around the fact that you cannot inspect the code before executing it with this method, that you can't verify the source of the code and that it teaches users bad habits of trusting in "magic commands" like these.
</p>]]></description>
      <pubDate>Fri, 21 Sep 2012 11:35:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Pim Elshoff's Blog: In favour of typing]]></title>
      <guid>http://www.phpdeveloper.org/news/17867</guid>
      <link>http://www.phpdeveloper.org/news/17867</link>
      <description><![CDATA[<p>
<i>Pim Elshoff</i> has a new post to his blog that shares his preference on <a href="http://www.pelshoff.com/2012/04/in-favour-of-typing">typing (keystrokes, not variables) in applications</a> (hint: he likes it):
</p>
<blockquote>
We sometimes conceive of ideas that are arduous to express in code. Like persisting data, or some other uncommon task (sarcasm). It's not difficult, but it takes a lot of keystrokes to write. Being problem solvers, we find it difficult doing this kind of manual labour, especially when machines can do it for us. Still, I would like to take this opportunity to say that typing rocks and solutions that save typing suck.
</blockquote>
<p>
He talks about the abstraction that frameworks provide (less typing, more work) and and some of the "magic" that comes with them. He gives specific examples of some of his pervious experience with frameworks (including some pains with Symfony2) and how some of the magic he's seen is easy to write but hard to read.
</p>]]></description>
      <pubDate>Wed, 25 Apr 2012 13:57:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Refulz.com: The __toString() Method - Objects as Strings]]></title>
      <guid>http://www.phpdeveloper.org/news/17523</guid>
      <link>http://www.phpdeveloper.org/news/17523</link>
      <description><![CDATA[<p>
On the Refulz.com blog there's a <a href="http://php.refulz.com/magic-methods-in-php-tostring-method/">recent post</a> introducing the __toString() magic method in PHP. This handy method allows you to define how to return an object when it's referenced as a string.
</p>
<blockquote>
We started the study of PHP magic methods by learning about <a href="http://php.refulz.com/magic-methods-in-php-__get-method/">__get() magic method</a>. [...] PHP is loosely typed language and same variable can be used or referred as string, number or object. The __toString() method is called when the code attempts to treat an object like a string. This function does not accept any arguments and should return a string.
</blockquote>
<p>
Some quick code is included showing how it works - returning a combined string made from two private class properties when the object ($obj) is echoed out. They also show multiple ways of using the method in both pre- and post-PHP 5.2.
</p>]]></description>
      <pubDate>Thu, 09 Feb 2012 09:27:19 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Bence Eros' Blog: Getters, setters, performance]]></title>
      <guid>http://www.phpdeveloper.org/news/16580</guid>
      <link>http://www.phpdeveloper.org/news/16580</link>
      <description><![CDATA[<p>
<i>Bence Eros</i> has put together <a href="http://erosbence.blogspot.com/2011/07/getters-setters-performance.html">a new post to his blog</a> looking at some of the results he's found from performance testing the use of getters and setters in PHP.
</p>
<blockquote>
The usage of getter and setter methods instead of public attributes became very popular in the PHP community, and it's going to become the standard coding convention of so many PHP libraries and frameworks. On the other hand many developers - including me too - strongly unrecommend such convention, because of its performance overhead. I wanted to make some performance comparison for years, and today I had time to do that. In this post I would like to show what I found.
</blockquote>
<p>
He starts with a question every developer asks as their working in their application - why and when should they use getters and setters for their classes. He talks about using them as primary functionality or as fallbacks only when needed. He includes the simple benchmarking script he used to compare accessing/setting public attributes directly and using a getter/setter to do the same. The results aren't very surprising if you think about the "magic" that has to happen for getters and setters to work. See <a href="http://erosbence.blogspot.com/2011/07/getters-setters-performance.html">the rest of the post</a> for those numbers.
</p>]]></description>
      <pubDate>Tue, 12 Jul 2011 11:39:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Web Developer Juice: PHP Magic Functions: Best Part of Object Oriented PHP - Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/16361</guid>
      <link>http://www.phpdeveloper.org/news/16361</link>
      <description><![CDATA[<p>
Web Developer Juice has posted <a href="http://www.webdeveloperjuice.com/2011/05/09/php-magic-functions-best-part-of-object-oriented-php-%E2%80%93-part-2/">the second part of their series</a> looking at some of the "magic functions" that PHP has to offer - special functions that do automagic things in your scripts and classes. Part one can be <a href="http://phpdeveloper.org/news/16288">found here</a>.
</p>
<blockquote>
In my <a href="http://www.webdeveloperjuice.com/2011/04/28/php-magic-functions-best-part-of-object-oriente-php/">previous post</a> ( PHP Magic Functions ), I discussed about __construct, __destruct, __call and __callStatic. Lets explore a few more magic functions...
</blockquote>
<p>In this latest part of the series they look at three functions:</p>
<ul>
<li>__set/__get
<li>__invoke
</ul>]]></description>
      <pubDate>Thu, 19 May 2011 10:14:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Web Developer Juice: PHP Magic Functions: Best Part of Object Oriented PHP - Part 1]]></title>
      <guid>http://www.phpdeveloper.org/news/16288</guid>
      <link>http://www.phpdeveloper.org/news/16288</link>
      <description><![CDATA[<p>
On the Web Developer Juice blog there's a <a href="http://www.webdeveloperjuice.com/2011/04/28/php-magic-functions-best-part-of-object-oriente-php/">recent post</a>, the first part in a series</a> looking at one of the more handy features of the recent releases of PHP - the magic functions (some which were added in the PHP 5.x series).
</p>
<blockquote>
There are some reserved function names  in PHP class starting with __ ( double underscore ). These are <a href="http://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor">__construct</a>, <a href="http://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.destructor">__destruct</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">__isset</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">__unset</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods">__call</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods">__callStatic</a>, <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep">__sleep</a>, <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep">__wakeup</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">__get</a>, <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">__set</a>, <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring">__toString</a>, <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.set-state">__set_state</a>, <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke">__invoke</a> and <a href="http://www.php.net/manual/en/language.oop5.cloning.php">__clone</a>. You cannot use these functions to serve your logical purpose but these are meant to be used for providing magic functionality.
</blockquote>
<p>
They go through some of the above methods and talk about what role they can play in your code and, for some, a brief bit of code to explain how it works. This first part covers __construct/__destruct and __call/__callStatic.
</p>]]></description>
      <pubDate>Tue, 03 May 2011 11:57:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: Dependency Injection: An analogy]]></title>
      <guid>http://www.phpdeveloper.org/news/16081</guid>
      <link>http://www.phpdeveloper.org/news/16081</link>
      <description><![CDATA[<p>
For those still grappling with the concept of dependency injection, <i>Matthew Weier O'Phinney</i> has <a href="http://weierophinney.net/matthew/archives/260-Dependency-Injection-An-analogy.html">posted an analogy</a> that could help make the concept a bit more clear.
</p>
<blockquote>
I've been working on a proposal for including service locators and dependency injection containers in Zend Framework 2.0, and one issue I've had is trying to explain the basic concept to developers unfamiliar with the concepts -- or with pre-conceptions that diverge from the use cases I'm proposing.
</blockquote>
<p>
Using his wife as a sample sounding board, he came up with a restaurant-based analogy to help explain the concept - asking for certain pre-planned things but wanting customizations. He reminds developers that there's not much "magic" to DI. Things are all well defined from the outset and you only have to use it when you want.
</p>]]></description>
      <pubDate>Tue, 22 Mar 2011 12:36:20 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jose da Silva's Blog: Revisiting PHP 5.3 __invoke magic method]]></title>
      <guid>http://www.phpdeveloper.org/news/15392</guid>
      <link>http://www.phpdeveloper.org/news/15392</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Jose da Silva</i> <a href="http://blog.josedasilva.net/revisiting-php-5-3-__invoke-magic-method/">briefly looks at</a> a feature that was introduced in the PHP 5.3.x series of the language - the __invoke magic method.
</p>
<blockquote>
PHP version 5.3 introduced a new magic method designed __invoke, this method is called when a script tries to call an object as a function. [...] As php cannot accommodate pseudo-first-class functions, the __invoke method can be used to suppress this language limitation. On other hand you can use this for simpler things as pass a function around. 
</blockquote>
<p>
He includes a simple code example that shows a basic class being called via a variable name - $c('ford') - and the result of its __invoke method being called. He notes that <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke">the method</a>, in his opinion, could make for less clean code.
</p>]]></description>
      <pubDate>Fri, 05 Nov 2010 12:42:04 -0500</pubDate>
    </item>
  </channel>
</rss>
