News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Renner's Blog:
Gerrymandered Code Extending Zend_Registry to globalize session vars
January 22, 2010 @ 10:29:50

Chris Renner has put together a new post showing how to use the Zend_Registry component of the Zend Framework to make your session variables easier to get to globally from other parts of your application (and standardize their access).

I've been using $_SESSION like this for a couple of years, and I've known the whole time it was a band-aid approach to solve the problem. Such an approach is not an ideal "design pattern." Though it passes my baseline rule - it works - there are downsides. [...] I refactoring my main app with Zend_Registry in place of my rat's nest of $_SESSION['config']['foo'] and such...which is mostly just things like email addresses for the system admin (me) and other global variables that may come in handy in any script or method.

He talks about how storing values in the session (especially configuration settings) is a bit of "Gerrymandered code" and that the Zend_Registry features allow you to completely replace the need for working directly with $_SESSION. To replace his current functionality, though, he still needed to work with the session values. The result? A wrapper class that has methods for getting and setting to make things a bit more clean.

0 comments voice your opinion now!
zendregistry zendframework global tutorial session


blog comments powered by Disqus

Similar Posts

PHPMaster.com: The MVC Pattern and PHP, Part 2

PHPRefresh.com: Managing Sessions and State with PHP

EasyTech Blog: Executing PL/SQL code in Zend Framework

PHPMac.com: Building and Installing Apache 2.2.2 and PHP 5.1.3 (or 5.1.4) on Mac OS X 10.4.6

Rob Allen's Blog: On models in a Zend Framework application


Community Events





Don't see your event here?
Let us know!


library package framework composer version interview symfony update community laravel podcast introduction mvc language security voicesoftheelephpant release opinion series tool

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework