<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Gerrymandered Code: Extending Zend_Registry to globalize session vars</title>
	<atom:link href="http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/</link>
	<description>Thoughts on PHP, MySQL and JavaScript/AJAX Web Development</description>
	<lastBuildDate>Wed, 25 Aug 2010 23:08:44 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: XPerez</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-251</link>
		<dc:creator>XPerez</dc:creator>
		<pubDate>Thu, 03 Jun 2010 08:25:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-251</guid>
		<description>Sorry, I forgot to include the url for datastorage clas:

http://code.google.com/p/datastorage/

Xavier Pérez</description>
		<content:encoded><![CDATA[<p>Sorry, I forgot to include the url for datastorage clas:</p>
<p><a href="http://code.google.com/p/datastorage/" rel="nofollow">http://code.google.com/p/datastorage/</a></p>
<p>Xavier Pérez</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: XPerez</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-250</link>
		<dc:creator>XPerez</dc:creator>
		<pubDate>Thu, 03 Jun 2010 08:23:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-250</guid>
		<description>Hi Chris.

Recently, I have created a new singleton class (datastorage), similar as Zend_Registry, but with namespaces and persistence included.

Would be interesting in extends Zend_Registry to make the same as my datastorage class ? Can be done ?

Thanks,

Xavier Pérez</description>
		<content:encoded><![CDATA[<p>Hi Chris.</p>
<p>Recently, I have created a new singleton class (datastorage), similar as Zend_Registry, but with namespaces and persistence included.</p>
<p>Would be interesting in extends Zend_Registry to make the same as my datastorage class ? Can be done ?</p>
<p>Thanks,</p>
<p>Xavier Pérez</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris  Renner</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-247</link>
		<dc:creator>Chris  Renner</dc:creator>
		<pubDate>Wed, 05 May 2010 12:17:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-247</guid>
		<description>I had to go back and check what ZF version I&#039;m running...and it happens to be 1.10.3

Latest is 1.10.4 but it doesn&#039;t look like there were any changes to Zend_Session on the latest release.  

So far there&#039;s no issues between my extension class and ZF 1.10</description>
		<content:encoded><![CDATA[<p>I had to go back and check what ZF version I&#8217;m running&#8230;and it happens to be 1.10.3</p>
<p>Latest is 1.10.4 but it doesn&#8217;t look like there were any changes to Zend_Session on the latest release.  </p>
<p>So far there&#8217;s no issues between my extension class and ZF 1.10</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris  Renner</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-246</link>
		<dc:creator>Chris  Renner</dc:creator>
		<pubDate>Tue, 04 May 2010 19:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-246</guid>
		<description>No but I&#039;ll work with it and let you know.</description>
		<content:encoded><![CDATA[<p>No but I&#8217;ll work with it and let you know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: latest gadget</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-245</link>
		<dc:creator>latest gadget</dc:creator>
		<pubDate>Tue, 04 May 2010 16:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-245</guid>
		<description>in the new zend 
Zend_Session_Namespace is completly changed

Any idea how it will work</description>
		<content:encoded><![CDATA[<p>in the new zend<br />
Zend_Session_Namespace is completly changed</p>
<p>Any idea how it will work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris  Renner</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-156</link>
		<dc:creator>Chris  Renner</dc:creator>
		<pubDate>Tue, 26 Jan 2010 18:37:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-156</guid>
		<description>Thanks for adding your thoughts Thinsolder.  I considered going the dependency injection route.  I already have that with my db connection object being passed to most of my classes.  I just find that approach messy and it adds properties to the objects that don&#039;t really need to be there all the time and in every instance.  Particularly if it is a value that is only needed in one method, and/or if it will be called statically, I like my approach better.</description>
		<content:encoded><![CDATA[<p>Thanks for adding your thoughts Thinsolder.  I considered going the dependency injection route.  I already have that with my db connection object being passed to most of my classes.  I just find that approach messy and it adds properties to the objects that don&#8217;t really need to be there all the time and in every instance.  Particularly if it is a value that is only needed in one method, and/or if it will be called statically, I like my approach better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thinsoldier</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-155</link>
		<dc:creator>thinsoldier</dc:creator>
		<pubDate>Tue, 26 Jan 2010 18:31:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-155</guid>
		<description>http://php.net/manual/en/reserved.variables.globals.php

If you needed config vars defined in global scope to be available within functions/class methods then all you had to do was use $GLOBALS[&#039;varname&#039;]; or the global keyword (http://php.net/manual/en/language.variables.scope.php)

I used to keep all my config vars in a globally defined $CONFIG array and access them like:
$conf = getConf();
echo $conf[&#039;dev&#039;][&#039;email&#039;]

Or write all your classes with dependency injection in mind and make sure you pass $CONFIG to the constructor for classes that need it when you instantiate objects  from them.

I also recently switched to using a singleton config class but I still access it through a function that returns the reference to the object.
echo Config()-&gt;Admin[&#039;email&#039;];
Config()-&gt;NewsletterUrl = &#039;foo.com/newsletter&#039;;
// no, a new object isn&#039;t created every time the config function is called

Mine still has issues tho. I&#039;ve run into problems getting it to work with static calls (Registry::get(&#039;foo&#039;)) and trying to make a class that extends it still returns the base registry class instead of the child class...</description>
		<content:encoded><![CDATA[<p><a href="http://php.net/manual/en/reserved.variables.globals.php" rel="nofollow">http://php.net/manual/en/reserved.variables.globals.php</a></p>
<p>If you needed config vars defined in global scope to be available within functions/class methods then all you had to do was use $GLOBALS['varname']; or the global keyword (<a href="http://php.net/manual/en/language.variables.scope.php" rel="nofollow">http://php.net/manual/en/language.variables.scope.php</a>)</p>
<p>I used to keep all my config vars in a globally defined $CONFIG array and access them like:<br />
$conf = getConf();<br />
echo $conf['dev']['email']</p>
<p>Or write all your classes with dependency injection in mind and make sure you pass $CONFIG to the constructor for classes that need it when you instantiate objects  from them.</p>
<p>I also recently switched to using a singleton config class but I still access it through a function that returns the reference to the object.<br />
echo Config()-&gt;Admin['email'];<br />
Config()-&gt;NewsletterUrl = &#8216;foo.com/newsletter&#8217;;<br />
// no, a new object isn&#8217;t created every time the config function is called</p>
<p>Mine still has issues tho. I&#8217;ve run into problems getting it to work with static calls (Registry::get(&#8217;foo&#8217;)) and trying to make a class that extends it still returns the base registry class instead of the child class&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris  Renner</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-153</link>
		<dc:creator>Chris  Renner</dc:creator>
		<pubDate>Tue, 26 Jan 2010 12:43:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-153</guid>
		<description>Hi Wil and thanks for the comments.  

Interesting question you ask re: Zend_Session_Namespace.  I am actually using it too, but for simplicity didn&#039;t discuss it in my post.  I&#039;m handling all session vars with Zend_Session_Namespace and then loading the namespace into Zend_Registry as an object.  

I chose this approach because my wrapper class still gives me a one line, one statement way to access the namespace properties.  To access using Zend_Session, I have to intantiate the namespace first, which creates a second (unnecessary) line of code in every place I need to access the session.  

I realize my approach is overkill, but so far I&#039;m pleased with the result.</description>
		<content:encoded><![CDATA[<p>Hi Wil and thanks for the comments.  </p>
<p>Interesting question you ask re: Zend_Session_Namespace.  I am actually using it too, but for simplicity didn&#8217;t discuss it in my post.  I&#8217;m handling all session vars with Zend_Session_Namespace and then loading the namespace into Zend_Registry as an object.  </p>
<p>I chose this approach because my wrapper class still gives me a one line, one statement way to access the namespace properties.  To access using Zend_Session, I have to intantiate the namespace first, which creates a second (unnecessary) line of code in every place I need to access the session.  </p>
<p>I realize my approach is overkill, but so far I&#8217;m pleased with the result.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wil Moore III</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-152</link>
		<dc:creator>Wil Moore III</dc:creator>
		<pubDate>Tue, 26 Jan 2010 05:47:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-152</guid>
		<description>Interesting article...thanks for sharing. I do have one comment and a question respectively:

1. You mentioned the trashing of the &quot;singleton&quot; pattern. Sometimes those that make arguments do it out of context. There really is no problem with the singleton pattern per-se; however, the problem is with developer mis-use/over-use of the pattern. The registry pattern is one good way to apply the singleton pattern. Another good use of the singleton pattern is with having a single entrypoint to a database connection object.

2. I have to ask: why did you chose the solution written about over simply using Zend_Session/Zend_Session_Namespace? I could be missing something but I&#039;m not sure I understand the merit.

Again, thanks for sharing and your article was well-written.

-Wil Moore III</description>
		<content:encoded><![CDATA[<p>Interesting article&#8230;thanks for sharing. I do have one comment and a question respectively:</p>
<p>1. You mentioned the trashing of the &#8220;singleton&#8221; pattern. Sometimes those that make arguments do it out of context. There really is no problem with the singleton pattern per-se; however, the problem is with developer mis-use/over-use of the pattern. The registry pattern is one good way to apply the singleton pattern. Another good use of the singleton pattern is with having a single entrypoint to a database connection object.</p>
<p>2. I have to ask: why did you chose the solution written about over simply using Zend_Session/Zend_Session_Namespace? I could be missing something but I&#8217;m not sure I understand the merit.</p>
<p>Again, thanks for sharing and your article was well-written.</p>
<p>-Wil Moore III</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris  Renner</title>
		<link>http://www.chrisrenner.com/2010/01/gerrymandered-code-using-zend_registry-to-globalize-session-vars/comment-page-1/#comment-149</link>
		<dc:creator>Chris  Renner</dc:creator>
		<pubDate>Mon, 25 Jan 2010 13:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisrenner.com/?p=293#comment-149</guid>
		<description>Derek, I implemented your suggestion this morning.  It works fine, if you remember to change the references to self::get and self::set in the two methods to Zend_Registry::get and Zend_Registry::set, respectively.  Otherwise the methods just loop back on themselves.  I&#039;m not sure there&#039;s a &quot;better&quot; way between the two styles, just coder preference from where I stand.  Nevertheless, I am going to keep it the way you suggested simply to shorten my calls.  Since the whole point of the post was simplifying my code, it just makes sense.</description>
		<content:encoded><![CDATA[<p>Derek, I implemented your suggestion this morning.  It works fine, if you remember to change the references to self::get and self::set in the two methods to Zend_Registry::get and Zend_Registry::set, respectively.  Otherwise the methods just loop back on themselves.  I&#8217;m not sure there&#8217;s a &#8220;better&#8221; way between the two styles, just coder preference from where I stand.  Nevertheless, I am going to keep it the way you suggested simply to shorten my calls.  Since the whole point of the post was simplifying my code, it just makes sense.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
