<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Federico Cargnelutti</title>
	<atom:link href="http://blog.fedecarg.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fedecarg.com</link>
	<description>Simple is better than complex. Complex is better than complicated. &#124; @fedecarg</description>
	<lastBuildDate>Wed, 03 Mar 2010 21:21:12 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='blog.fedecarg.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/92b6a280735bcc315d537f1f70767bf0?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Federico Cargnelutti</title>
		<link>http://blog.fedecarg.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.fedecarg.com/osd.xml" title="Federico Cargnelutti" />
	<atom:link rel='hub' href='http://blog.fedecarg.com/?pushpress=hub'/>
		<item>
		<title>Review: Zend Framework 1.8 Web Application Development</title>
		<link>http://blog.fedecarg.com/2009/12/11/review-zend-framework-1-8-web-application-development/</link>
		<comments>http://blog.fedecarg.com/2009/12/11/review-zend-framework-1-8-web-application-development/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 11:50:40 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1880</guid>
		<description><![CDATA[Zend Framework is one of the most popular and hottest open-source frameworks being used today. The number of books about Web development using Zend Framework has increased over the last couple of years.
Packt Publishing sent me a copy of the book Zend Framework 1.8 Web Application Development by Keith Pope to review. I found this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1880&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Zend Framework is one of the most popular and hottest open-source frameworks being used today. The number of books about Web development using Zend Framework has increased over the last couple of years.</p>
<p>Packt Publishing sent me a copy of the book <a href="http://www.packtpub.com/zend-framework-1-8-web-application-development/book" target="_blank">Zend Framework 1.8 Web Application Development</a> by <a href="http://www.thepopeisdead.com/" target="_blank">Keith Pope</a> to review. I found this book to be a good introduction to the topics that a Zend Framework developer will need to know when developing enterprise Web applications. The book is also aimed at advanced users, considering there were a couple of things that I learned about this framework from reading the book. The book not only shows you how the Zend Framework works, but also how to write an application for real-world usage. The book covers access control, performance optimization, testing, debugging and application design. The writing is clear, the <a href="http://code.google.com/p/zendframeworkstorefront/source/browse" target="_blank">code examples are good</a> and Keith does an excellent job of walking you through the life-cycle of a request, explaining how things work and how you can extend the framework to fit your needs.</p>
<p>Here&#8217;s an example of the Storefront application:<br />
<a href="http://code.google.com/p/zendframeworkstorefront/source/browse" target="_blank">http://code.google.com/p/zendframeworkstorefront/source/browse</a></p>
<h3>Conclusion</h3>
<p>The book is very well-written, nicely structured and full of highly practical advice. Overall, I&#8217;m happy to say that <a href="http://www.packtpub.com/zend-framework-1-8-web-application-development/book" target="_blank">Zend Framework 1.8 Web Application Development</a> fulfilled my expectations.</p>
<h3>Other Reviews</h3>
<p><a href="http://raphaelstolt.blogspot.com/2009/10/zend-framework-18-web-application.html" target="_blank">Raphael Stolt</a></p>
<p>&#8220;The content of the book is delivered in a fluent, very enthusiastic and &#8216;knowledge-pillowed&#8217; writing tone. By implementing or working through the Storefront application seasoned web developers using older versions of the Framework will get a good blue sheet on new components like Zend_Application and it&#8217;s implication in the bootstrapping process; while new developers tending towards picking up the Zend Framework will get a current and well compiled guide, which might first start off with a steep learning-curve but will turn into profund knowledge once hanging in there.&#8221;</p>
<p><a href="http://net.tutsplus.com/articles/reviews/book-review-zend-framework-1-8-web-application-development" target="_blank">Fred Wu</a></p>
<p>&#8220;The flow of this book is heavily inspired by the famous Ruby on Rails book, Agile Web Development with Rails, where the author invites you to join the process of building a demo application, which in both cases is a shopping cart system. Judging by the feedback of the Rails book, most people feel quite comfortable learning a framework this way, some don&#8217;t. I guess if you are not a fan of following a defined learning structure, this book probably isn&#8217;t for you.&#8221;</p>
<br />Posted in Design Patterns, Frameworks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1880/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1880/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1880/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1880/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1880/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1880/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1880/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1880/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1880/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1880/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1880&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/12/11/review-zend-framework-1-8-web-application-development/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Sky Named Britain&#8217;s Most Admired Company</title>
		<link>http://blog.fedecarg.com/2009/12/06/sky-named-britains-most-admired-company/</link>
		<comments>http://blog.fedecarg.com/2009/12/06/sky-named-britains-most-admired-company/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 20:40:51 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Awards]]></category>
		<category><![CDATA[linkedin.]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1867</guid>
		<description><![CDATA[Based on a survey of thousands of managers and investment analysts, Management Today has named BSkyB as Britain&#8217;s Most Admired Company for 2009. BSkyB is the youngest company ever to win this Award.
BSkyB beat off the superstore giant Tesco into second place. Johnson Mathey took the third slot, with Cadbury, GlaxoSmithKline and Rolls-Royce trailing at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1867&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Based on a survey of thousands of managers and investment analysts, <a href="http://managementtoday.co.uk/channel/StrategyOperations/news/970753/bskyb-britains-admired-company-2009/" target="_blank">Management Today</a> has named BSkyB as Britain&#8217;s Most Admired Company for 2009. BSkyB is the youngest company ever to win this Award.</p>
<p>BSkyB beat off the superstore giant Tesco into second place. Johnson Mathey took the third slot, with Cadbury, GlaxoSmithKline and Rolls-Royce trailing at numbers four, five and six.</p>
<p>BSkyB headed off the sector in all of the criteria laid down by the organizers, coming out top in &#8220;quality of goods and services&#8221;, &#8220;quality of marketing&#8221; and &#8220;capacity to innovate&#8221;.</p>
<h3>Most Admired Top 20, 2009</h3>
<p>(Last year&#8217;s position in brackets)</p>
<pre>1 (4)     BSkyB 72.25
2 (5)     Tesco 71.38
3 (2)     Johnson Matthey 71.00
4 (18)    Cadbury 70.40
5 (19)    GlaxoSmithKline 70.00
6 (7)     Rolls-Royce 69.96
7 (26)    BP 67.08
8 (11)    BG Group 67.03
9 (1)     Diageo 65.83
10 (47)   Cobham 65.75
11 (3)    Unilever 65.0
12 (52)   BAE Systems 64.9
13 (51)   Ultra Electronics 64.7
14 (154)  Centrica 64.4
14 (24)   Royal Dutch Shell 64.4
16 (81)   Admiral 63.9
16 (17)   Capita Group 63.9
18 (27)   Sainsbury 63.8
19 (55)   Balfour Beatty 63.1
20 (29)   Marks &amp; Spencer 62.9
</pre>
<p>BSkyB is a great company to work for, filled with talented people. Congratulation for this prestigious award!</p>
<h3>Links</h3>
<p><a href="http://bit.ly/4njswp">Management Today</a><a href="http://news.sky.com/skynews/Home/Business/BSkyB-Is-Named-UKs-Most-Admired-Company-By-Management-Today/Article/200912115482904?f=rss" target="_blank"><br />
Sky News</a></p>
<br />Posted in Awards Tagged: linkedin. <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1867/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1867/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1867/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1867/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1867/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1867&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/12/06/sky-named-britains-most-admired-company/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Command-line memcached stat reporter</title>
		<link>http://blog.fedecarg.com/2009/11/29/command-line-memcached-stat-reporter/</link>
		<comments>http://blog.fedecarg.com/2009/11/29/command-line-memcached-stat-reporter/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 15:28:44 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Open-source]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1848</guid>
		<description><![CDATA[Nicholas Tang wrote a nice little perl script that shows a basic memcached top display for a list of servers. You can specify thresholds, for instance, and it&#8217;ll change color to red if you exceed the thresholds. You can also choose the refresh/sleep time, and whether to show immediate (per second) stats, or lifetime stats.
To [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1848&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://nicholasytang.wordpress.com/" target="_blank">Nicholas Tang</a> wrote a nice little perl script that shows a basic memcached top display for a list of servers. You can specify thresholds, for instance, and it&#8217;ll change color to red if you exceed the thresholds. You can also choose the refresh/sleep time, and whether to show immediate (per second) stats, or lifetime stats.</p>
<p>To install it you only need to download the script and make it executable:</p>
<pre>$ curl http://memcache-top.googlecode.com/files/memcache-top-v0.6 &gt; ~/bin/memcache-top
$ chmod +x ~/bin/memcache-top
$ memcache-top --sleep 3 --instances 10.50.11.3,10.50.11.4,10.50.11.5
</pre>
<p>Here&#8217;s some sample output:</p>
<pre>memcache-top v0.6       (default port: 11211, color: on, refresh: 3 seconds)

INSTANCE                USAGE   HIT %   CONN    TIME    EVICT/s GETS/s  READ/s  WRITE/s
10.50.11.3:11211        88.9%   69.7%   1661    0.9ms   0.3     47      13.9K   9.8K
10.50.11.4:11211        88.8%   69.9%   2121    0.7ms   1.3     168     17.6K   68.9K
10.50.11.5:11211        88.9%   69.4%   1527    0.7ms   1.7     48      14.4K   13.6K
AVERAGE:                84.7%   72.9%   1704    1.0ms   1.3     69      13.5K   30.3K   

TOTAL:          19.9GB/ 23.4GB          20.0K   11.7ms  15.3    826     162.6K  363.6K
(ctrl-c to quit.)
</pre>
<p>Project Home<br />
<a href="http://code.google.com/p/memcache-top/" target="_blank">http://code.google.com/p/memcache-top/</a></p>
<br />Posted in Open-source, Tools  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1848/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1848&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/11/29/command-line-memcached-stat-reporter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Managing Multiple Build Environments</title>
		<link>http://blog.fedecarg.com/2009/11/14/managing-multiple-build-environments/</link>
		<comments>http://blog.fedecarg.com/2009/11/14/managing-multiple-build-environments/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 18:31:15 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[linkedin.]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1822</guid>
		<description><![CDATA[Last updated: 3 March, 2010
One of the challenges of Web development is managing multiple build environments. Most applications pass through several environments before they are released. These environments include: A local development environment, a shared development environment, a system integration environment, a user acceptance environment and a production environment.
Automated Builds
Automated builds provide a consistent method [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1822&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Last updated: 3 March, 2010</strong></p>
<p>One of the challenges of Web development is managing multiple build environments. Most applications pass through several environments before they are released. These environments include: A local development environment, a shared development environment, a system integration environment, a user acceptance environment and a production environment.</p>
<h3>Automated Builds</h3>
<p>Automated builds provide a consistent method for building applications and are used to give other developers feedback about whether the code was successfully integrated or not. There are different types of builds: Continuous builds, Integration builds, Release builds and Patch builds.</p>
<p>A source control system is the main point of integration for source code. When your team works on separate parts of the code base, you have to ensure that your checked in code doesn&#8217;t break the Integration build. That&#8217;s why it is important that you run your unit tests locally before checking in code.</p>
<p>Here is a recommended process for checking code into source control:</p>
<ul>
<li>Get the latest code from source control before running your tests</li>
<li>Verify that your local build is building and passing all the unit tests before checking in code</li>
<li>Use hooks to run a build after a transaction has been committed</li>
<li>If the Integration build fails, fix the issue because you are now blocking other developers from integrating their code</li>
</ul>
<p>Hudson can help you automate these tasks. It&#8217;s extremely <a href="http://www.davegardner.me.uk/blog/2009/11/09/continuous-integration-for-php-using-hudson-and-phing/" target="_blank">easy to install</a> and can be configured entirely from a Web UI. Also, it can be extended via plug-ins and can execute Phing, Ant, Gant, NAnt and Maven build scripts.</p>
<h3>Build File</h3>
<p>We need to create a master build file that contains the actions we want to perform. This script should make it possible to build the entire project with a single command line.</p>
<p>First we need to separate the source from the generated files, so our source files will be in the &#8220;src&#8221; directory and all the generated files in the &#8220;build&#8221; directory. By default Ant uses build.xml as the name for a build file, this file is usually located in the project root directory.</p>
<p>Then, you have to define whatever environments you want:</p>
<pre>project/
    build/
        files/
            local/
            development/
            integration/
            production/
        packages/
            development/
                project-development-0.1-RC.noarch.rpm
            integration/
            production/
        default.properties
        local.properties
        development.properties
        production.properties
    src/
        application/
            config/
            controllers/
            domain/
            services/
            views/
        library/
        public/
    tests/
    build.xml</pre>
<p>Build files tend to contain the same actions:</p>
<ul>
<li>Delete the previous build directory</li>
<li>Copy files</li>
<li>Manage dependencies</li>
<li>Run unit tests</li>
<li>Generate HTML and XML reports</li>
<li>Package files</li>
</ul>
<p>The target element is used as a wrapper for a sequences of actions. A target has a name, so that it can be referenced from elsewhere, either externally from the command line or internally via the &#8220;depends&#8221; or &#8220;antcall&#8221; keyword. Here&#8217;s a basic build.xml example:</p>
<pre>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;project name="project" basedir="." default="main"&gt;

    &lt;target name="init"&gt;&lt;/target&gt;
    &lt;target name="test"&gt;&lt;/target&gt;
    &lt;target name="test-selenium"&gt;&lt;/target&gt;
    &lt;target name="profile"&gt;&lt;/target&gt;
    &lt;target name="clean"&gt;&lt;/target&gt;
    &lt;target name="build" depends="init, test, profile, clean"&gt;&lt;/target&gt;
    &lt;target name="package"&gt;&lt;/target&gt;

&lt;/project&gt;</pre>
<p>The property element allows the declaration of properties which are like user-definable variables available for use within an Ant build file. Properties can be defined either inside the buildfile or in a standalone properties file. For example:</p>
<pre>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;project name="project" basedir="." default="main"&gt;

    &lt;property file="${basedir}/build/default.properties" /&gt;
    &lt;property file="${basedir}/build/${build.env}.properties" /&gt;
    ...

&lt;/project&gt;</pre>
<p>The core idea is using property files which name accords to the environment name. Then simply use the custom build-in property build.env. For better use you should also provide a file with default values. The following example intends to describe a typical Ant build file, of course, it can be easily modified to suit your personal needs.</p>
<pre>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;project name="project" basedir="." default="main"&gt;

    &lt;property file="${basedir}/build/default.properties" /&gt;
    &lt;condition property="build.env" value="${build.env}" else="local"&gt;
        &lt;isset property="build.env" /&gt;
    &lt;/condition&gt;
    &lt;property file="${basedir}/build/${build.env}.properties" /&gt;

     &lt;property environment="env" /&gt;
     &lt;condition property="env.BUILD_ID" value="${env.BUILD_ID}" else=""&gt;
         &lt;isset property="env.BUILD_ID" /&gt;
     &lt;/condition&gt;

    &lt;target name="init"&gt;
        &lt;echo message="Environment: ${build.env}"/&gt;
        &lt;echo message="Hudson build ID: ${env.BUILD_ID}"/&gt;
        &lt;echo message="Hudson build number: ${env.BUILD_NUMBER}"/&gt;
        &lt;echo message="SVN revision: ${env.SVN_REVISION}"/&gt;
        &lt;tstamp&gt;
            &lt;format property="build.datetime" pattern="dd-MMM-yy HH:mm:ss"/&gt;
        &lt;/tstamp&gt;
        &lt;echo message="Build started at ${build.datetime}"/&gt;
    &lt;/target&gt;

    &lt;target name="test"&gt;
        ...
    &lt;/target&gt;

    &lt;target name="clean"&gt;
        &lt;delete dir="${build.dir}/files/${build.env}"/&gt;
        &lt;delete dir="${build.dir}/packages/${build.env}"/&gt;
        &lt;mkdir dir="${build.dir}/files/${build.env}"/&gt;
        &lt;mkdir dir="${build.dir}/packages/${build.env}"/&gt;
    &lt;/target&gt;

    &lt;target name="build" depends="init, test, profile, clean"&gt;
        ...
    &lt;/target&gt;
    ...

&lt;/project&gt;</pre>
<p>Using ant -Dname=value lets you define values for properties on the Ant command line. These properties can then be used within your build file as any normal property: ${name} will put in value.</p>
<pre>$ ant build -Dbuild.env=development
</pre>
<p>There are different ways to target multiple environments. I hope I have covered enough of the basic functionality to get you started.</p>
<br />Posted in Agile Development, Deployment, Java, Linux, PHP, Tools, Web Apps Tagged: linkedin. <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1822/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1822/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1822/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1822/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1822/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1822/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1822&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/11/14/managing-multiple-build-environments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing Zend Framework Action Controllers With Mocks</title>
		<link>http://blog.fedecarg.com/2009/11/01/testing-zend-framework-action-controllers-with-mocks/</link>
		<comments>http://blog.fedecarg.com/2009/11/01/testing-zend-framework-action-controllers-with-mocks/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 13:33:21 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1784</guid>
		<description><![CDATA[In this post I&#8217;ll demonstrate a unit test technique for testing Zend Framework Action Controllers using Mock Objects. Unit testing controllers independently has a number of advantages:

You can develop controllers test-first (TDD).
It allows you to develop and test all of your controller code before developing any of the view scripts.
It helps you quickly identify problems [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1784&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll demonstrate a unit test technique for testing Zend Framework Action Controllers using Mock Objects. Unit testing controllers independently has a number of advantages:</p>
<ol>
<li>You can develop controllers test-first (TDD).</li>
<li>It allows you to develop and test all of your controller code before developing any of the view scripts.</li>
<li>It helps you quickly identify problems in the controller, rather than problems in one of the combination of Model, View and Controller.</li>
</ol>
<p>The Action Controller I&#8217;m going to test has only one method, profileAction():</p>
<p><strong>tests/application/controllers/UserController.php</strong></p>
<pre>class UserController extends Zend_Controller_Action
{
    public function profileAction()
    {
        $this-&gt;view-&gt;userId = $this-&gt;_getParam('user_id');
        return $this-&gt;render();
    }
}</pre>
<p><strong>tests/application/ControllerTestCase.php</strong></p>
<pre>class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
    public $application;

    public function setUp()
    {
        $this-&gt;application = new Zend_Application(
            APPLICATION_ENV,
            APPLICATION_PATH . '/config/application.ini'
        );

        $this-&gt;bootstrap = array($this, 'bootstrap');
        parent::setUp();
    }

    public function tearDown()
    {
        Zend_Controller_Front::getInstance()-&gt;resetInstance();

        $this-&gt;resetRequest();
        $this-&gt;resetResponse();

        $this-&gt;request-&gt;setPost(array());
        $this-&gt;request-&gt;setQuery(array());
    }

    public function bootstrap()
    {
        $this-&gt;application-&gt;bootstrap();
    }
}</pre>
<p><strong>tests/application/controllers/UserControllerTest.php</strong></p>
<pre>require_once TESTS_PATH . '/application/ControllerTestCase.php';
require_once APPLICATION_PATH . '/controllers/UserController.php';

class UserControllerTest extends ControllerTestCase
{
    public function testStubRenderMethodCall()
    {
        $request = $this-&gt;getRequest()
            -&gt;setRequestUri('/user/profile/1')
            -&gt;setParams(array('user_id'=&gt;1))
            -&gt;setPathInfo(null);

        $response = $this-&gt;getResponse();

        $this-&gt;getFrontController()
            -&gt;setRequest($request)
            -&gt;setResponse($response)
            -&gt;throwExceptions(true)
            -&gt;returnResponse(false);

        $controller = $this-&gt;getMock(
            'UserController',
            array('render'),
            array($request, $response, $request-&gt;getParams())
        );
        $controller-&gt;expects($this-&gt;once())
                 -&gt;method('render')
                 -&gt;will($this-&gt;returnValue(true));

        $this-&gt;assertTrue($controller-&gt;profileAction());
        $this-&gt;assertTrue($controller-&gt;view-&gt;user_id == 1);
    }
}</pre>
<p>You can go further making both the tests and the implementation more sophisticated. The main point is that you can build and test a controller in a way that doesn&#8217;t require a view script to be written to do so.</p>
<h3>Zend Framework Known Issues</h3>
<p>By default Zend_Test_PHPUnit_ControllerTestCase sets the redirector exit value to false, leading to unexpected behavior when unit testing your code. For that reason, make sure you always add a return statement after calling a utility method:</p>
<pre>class UserController extends Zend_Controller_Action
{
    public function profileAction()
    {
        if (null == $this-&gt;_getParam('user_id', null) {
            return $this-&gt;_redirect('/');
        }
        return $this-&gt;render();
    }
}</pre>
<p>If you want the Front Controller to throw exceptions, you have no other choice than to overwrite the dispatch method and pass a boolean TRUE to the throwExceptions() method:</p>
<pre>class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
    ...

    public function dispatch($url = null)
    {
        // redirector should not exit
        $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
        $redirector-&gt;setExit(false);

        // json helper should not exit
        $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
        $json-&gt;suppressExit = true;

        $request = $this-&gt;getRequest();
        if (null !== $url) {
            $request-&gt;setRequestUri($url);
        }
        $request-&gt;setPathInfo(null);

        $this-&gt;getFrontController()
             -&gt;setRequest($request)
             -&gt;setResponse($this-&gt;getResponse())
             -&gt;throwExceptions(true)
             -&gt;returnResponse(false);

        $this-&gt;getFrontController()-&gt;dispatch();
    }

    ...
}
</pre>
<p>The Dispatcher not only <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Directory+-+Federico+Cargnelutti" target="_blank">violates the DRY principle</a> but also suffers from amnesia. The problem is that it doesn&#8217;t store the instance of the Action Controller, instead, it destroys it (Zend_Controller_Dispatcher_Standard Line 305). You can easily get around this issue by extending the standard dispatcher and overwriting the dispatch() method:</p>
<pre>class Zf_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Standard
{
    ...

    public function dispatch($url = null)
    {
        ...
        Zend_Registry::set('Zend_Controller_Action', $controller);

        // Destroy the page controller instance and reflection objects
        $controller = null;
    }
</pre>
<p>This will allow you to access the view object after dispatching the request:</p>
<pre>class ExampleControllerTest extends ControllerTestCase
{
    public function testDefaultActionRendersViewObject()
    {
        $this-&gt;dispatch('/');

        $controller = Zend_Registry::get('Zend_Controller_Action');

        $this-&gt;assertEquals('ExampleController', get_class($controller));
        $this-&gt;assertTrue(isset($controller-&gt;view));
    }
</pre>
<h3>Links</h3>
<p><a href="http://blog.fedecarg.com/2008/12/27/phpunit-testing-zend-framework-controllers/" target="_blank">PHPUnit: Testing Zend Framework Controllers</a><br />
<a href="http://www.phpunit.de/manual/3.4/en/test-doubles.html" target="_blank">PHPUnit: Mock Objects</a></p>
<br />Posted in Agile Development, Frameworks, PHP  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1784/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1784&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/11/01/testing-zend-framework-action-controllers-with-mocks/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Symfony 1.3 Web Application Development</title>
		<link>http://blog.fedecarg.com/2009/10/13/symfony-1-3-web-application-development/</link>
		<comments>http://blog.fedecarg.com/2009/10/13/symfony-1-3-web-application-development/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:24:55 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1767</guid>
		<description><![CDATA[Packt Publishing recently sent me a copy of the book &#8220;Symfony 1.3 Web Application Development&#8221; to review.
This book is not a reference guide, but an example driven tutorial that takes you through the process of building Model-View-Controller-based web applications. You will learn how to create and develop a simple online store application. It also covers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1767&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Packt Publishing recently sent me a copy of the book &#8220;<a href="http://www.packtpub.com/symfony-1-3-web-application-development" target="_blank">Symfony 1.3 Web Application Development</a>&#8221; to review.</p>
<p>This book is not a reference guide, but an example driven tutorial that takes you through the process of building Model-View-Controller-based web applications. You will learn how to create and develop a simple online store application. It also covers best practices for better and quicker application development.</p>
<p>The book is based on the latest version of the Symfony Framework, and does a great job telling you what you get out of the box and how it works, which is perfect for hitting the ground running. During the development you are introduced to the concepts and features of the MVC framework. However, for those who want to know more about the framework, the book doesn&#8217;t explain how things work under the covers. This book is more for beginners who want to get started with Symfony 1.3.</p>
<p>One thing I didn&#8217;t like about this book is that it uses Propel instead of Doctrine as the default ORM framework. Apart from that, it does a great job explaining and demonstrating with practical examples how to build a Web application from scratch.</p>
<p>Overall, and considering that some of the topics in this book have already been covered in <a href="http://www.symfony-project.org/jobeet/1_3/Doctrine/en/" target="_blank">Practical Symfony 1.3</a>, I rate this book 4 out of 5.</p>
<p><a href="http://www.packtpub.com/symfony-1-3-web-application-development" target="_blank">Symfony 1.3 Web Application Development</a></p>
<br />Posted in Frameworks, PHP  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1767/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1767&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/10/13/symfony-1-3-web-application-development/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Replication Adapter for Zend Framework Applications</title>
		<link>http://blog.fedecarg.com/2009/10/02/database-replication-adapter-for-zend-framework-applications/</link>
		<comments>http://blog.fedecarg.com/2009/10/02/database-replication-adapter-for-zend-framework-applications/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 15:29:17 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Open-source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1746</guid>
		<description><![CDATA[Database replication is an option that allows the content of one database to be replicated to another database or databases, providing a mechanism to scale out the database. Scaling out the database allows more activities to be processed and more users to access the database by running multiple copies of the databases on different machines.
The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1746&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Database replication is an option that allows the content of one database to be replicated to another database or databases, providing a mechanism to scale out the database. Scaling out the database allows more activities to be processed and more users to access the database by running multiple copies of the databases on different machines.</p>
<p>The problem with <a href="http://blog.digg.com/?p=213" target="_blank">monolithic database designs</a> is that they don&#8217;t establish an infrastructure that allows for rapid changes in business requirements. Here is where database replication comes into play. Replication can be used effectively for many different purposes, such as separating data entry and reporting, distributing load across servers, providing high availability, etc.</p>
<p>In 2008, Paul M. Jones <a href="http://www.solarphp.com/blog/read/19-adapter-for-master-slave-my-sql-setups" target="_blank">announced</a> the release of an SQL adapter that allows Solar users to connect to master/slave database installations. My first reaction was: Great! This will inspire other FOSS developers to create similar components. And guess what, it did. I wrote my own ReplicationAdapter. It&#8217;s not great, but it&#8217;s flexible enough to support the most commonly used replication scenarios:</p>
<h3>Single-Master Replication</h3>
<p>In the simplest replication scenario, the master copy of directory data is held in a single read-write replica on one server called the supplier server. The supplier server also maintains changelog for this replica. On another server, called the consumer server, there can be multiple read-only replicas.</p>
<p>Configuration array:</p>
<pre>$db = array(
    'adapter'        =&gt; 'Pdo_Mysql',
    'driver_options' =&gt; array(PDO::ATTR_TIMEOUT=&gt;5),
    'username'       =&gt; 'root',
    'password'       =&gt; 'root',
    'dbname'         =&gt; 'test',
    'master_servers' =&gt; 1,
    'servers'        =&gt; array(
        array('host' =&gt; 'db.master-1.com'),
        array('host' =&gt; 'db.slave-1.com'),
        array('host' =&gt; 'db.slave-2.com')
    )
);

// or ...

$db = array(
    'adapter'        =&gt; 'Pdo_Mysql',
    'driver_options' =&gt; array(PDO::ATTR_TIMEOUT=&gt;5),
    'dbname'         =&gt; 'test',
    'master_servers' =&gt; 1,
    'servers'        =&gt; array(
        array('host' =&gt; 'db.master-1.com', 'username' =&gt; 'user1', 'password'=&gt;'pass1'),
        array('host' =&gt; 'db.slave-1.com', 'username' =&gt; 'user2', 'password' =&gt; 'pass2'),
        array('host' =&gt; 'db.slave-2.com', 'username' =&gt; 'user3', 'password' =&gt; 'pass3')
    )
);

Zend_Registry::set('db_config_array', $db);</pre>
<p>In the setup above, all writes will go to the master connection and all reads will be randomly distributed across the available slaves.</p>
<h3>Multi-Master Replication</h3>
<p>This type of configuration can work with any number of consumer servers. Each consumer server holds a read-only replica. The consumers can receive updates from all the suppliers. The consumers also have referrals defined for all the suppliers to forward any update requests that the consumers receive.</p>
<pre>$db = array(
    'adapter'        =&gt; 'Pdo_Mysql',
    'driver_options' =&gt; array(PDO::ATTR_TIMEOUT=&gt;5),
    'username'       =&gt; 'root',
    'password'       =&gt; 'root',
    'dbname'         =&gt; 'test',
    'master_servers' =&gt; 2,
    'master_read'    =&gt; true,
    'servers'        =&gt; array(
        array('host' =&gt; 'db.master-1.com'),
        array('host' =&gt; 'db.master-2.com')
    )
);

Zend_Registry::set('db_config_array', $db);</pre>
<h3>Using a distributed memory caching system</h3>
<p>Database connections are expensive and it&#8217;s very inefficient for an application to try to connect to a server that is down or not responding. A distributed memory caching system can help alleviate this problem by keeping a list of all the failed connections in memory, sharing that information across multiple servers and allowing the application to access it before attempting to open a connection.</p>
<p>To enable this option, you have to register an instance of the Memcached adapter class:</p>
<pre>Zend_Registry::set('db_config_array', $db);
...

$cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_Memcached', $f, $b);
Zend_Registry::set('Zend_Cache', $cache);</pre>
<h3>Zend Framework Example</h3>
<p>Here is a short and simple example of how the ReplicationAdapter might be used in a ZF application:</p>
<pre>class SingleMasterDb extends Zf_Db_ReplicationAdapter
{
    public function fecthAll()
    {
        $db = $this-&gt;getConnection('slave');
        $query = $db-&gt;select()-&gt;from('test');
        return $db-&gt;fetchAll($query);
    }

    public function insert($data)
    {
        $db = $this-&gt;getConnection('master');
        $db-&gt;insert('test', $data);
        return $db-&gt;lastInsertId();
    }

    public function update($id, $data)
    {
        $db = $this-&gt;getConnection('master');
        $where = $db-&gt;quoteInto('id = ?', $id);
        return $db-&gt;update('test', $data, $where);
    }
}</pre>
<p>Source Code:<br />
<a href="http://fedecarg.com/repositories/show/zfreplicationadapter" target="_blank">http://fedecarg.com/repositories/show/zfreplicationadapter</a></p>
<br />Posted in Databases, Frameworks, Open-source, Programming  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1746/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1746&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/10/02/database-replication-adapter-for-zend-framework-applications/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding theme support to your Zend Framework application</title>
		<link>http://blog.fedecarg.com/2009/09/20/adding-theme-support-to-your-zend-framework-application/</link>
		<comments>http://blog.fedecarg.com/2009/09/20/adding-theme-support-to-your-zend-framework-application/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 22:43:45 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Open-source]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1731</guid>
		<description><![CDATA[This is a brief explanation on how to add theme support to your Zend Framework application and how to ensure those themes are self-contained, easy to distribute and install.
Themes are very powerful and extremely easy to develop. They allow you to quickly switch between layouts and change the look and feel of your application. You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1731&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>This is a brief explanation on how to add theme support to your Zend Framework application and how to ensure those themes are self-contained, easy to distribute and install.</p>
<p>Themes are very powerful and extremely easy to develop. They allow you to quickly switch between layouts and change the look and feel of your application. You can use themes to show, for example, a mobile friendly version of your site.</p>
<p>Making a Zend Framework application theme-able is a three-step process.</p>
<p>First, modify your directory structure:</p>
<pre>application/
    controllers/
library/
public/
    themes/
        default/
            css/
            images/
            templates/
        custom/
            css/
            images/
            templates/</pre>
<p>Then, edit your Bootstrap class:</p>
<pre>class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initView()
    {
        $theme = 'default';
        if (isset($this-&gt;config-&gt;app-&gt;theme)) {
            $theme = $this-&gt;config-&gt;app-&gt;theme;
        }
        $path = PUBLIC_PATH.'/themes/'.$theme.'/templates';

        $layout = Zend_Layout::startMvc()
            -&gt;setLayout('layout')
            -&gt;setLayoutPath($path)
            -&gt;setContentKey('content');

        $view = new Zend_View();
        $view-&gt;setBasePath($path);
        $view-&gt;setScriptPath($baseDir);

        return $view;
    }
}</pre>
<p>And finally, copy your view scripts and layouts to the templates directory:</p>
<pre>application/
library/
public/
    themes/
        full-site/
            css/
            images/
            templates/
                error/
                index/
                partials/
                layout.phtml
        mobile-site/
            css/
            images/
            templates/</pre>
<p>Voila, mission accomplished.</p>
<br />Posted in Frameworks, Open-source, PHP  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1731/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1731/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1731/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1731/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1731/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1731/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1731/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1731/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1731/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1731/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1731&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/09/20/adding-theme-support-to-your-zend-framework-application/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework DAL: DAOs and DataMappers</title>
		<link>http://blog.fedecarg.com/2009/09/19/zend-framework-dal-daos-and-datamappers/</link>
		<comments>http://blog.fedecarg.com/2009/09/19/zend-framework-dal-daos-and-datamappers/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 12:23:22 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Architecture]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1713</guid>
		<description><![CDATA[A Data Access Layer (DAL) is the layer of your application that provides simplified access to data stored in persistent storage of some kind. For example, the DAL might return a reference to an object complete with its attributes instead of a row of fields from a database table.
A Data Access Objects (DAO) is used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1713&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>A Data Access Layer (DAL) is the layer of your application that provides simplified access to data stored in persistent storage of some kind. For example, the DAL might return a reference to an object complete with its attributes instead of a row of fields from a database table.</p>
<p>A Data Access Objects (DAO) is used to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data. Also, it implements the access mechanism required to work with the data source. The data source could be a persistent store like a database, a file or a Web service.</p>
<p>And finally, a DataMapper is used to move data between the object and a database while keeping them independent of each other. The DataMapper main responsibility is to transfer data between the two and also to isolate them from each other.</p>
<h3>Zend Framework Example</h3>
<pre>app/
    controllers/
        UserController.php
    views/
lib/
    Project/
        Dao/
            Db/
                User.php
            Service/
                User.php
        DataMapper/
            User.php
        Entity/
            User.php
        Model/
            User.php
    Zf/
        DataSource/
            Dao/
                Mapper.php
        Domain/
            Entity.php
        Db/
            Adapter.php</pre>
<h3>Database Table Structure</h3>
<pre>CREATE TABLE `user` (
 `id` int(11) NOT NULL auto_increment,
 `first_name` varchar(100) NOT NULL,
 `last_name` varchar(100) NOT NULL,
 PRIMARY KEY  (`id`)
)</pre>
<h3>The User DAO</h3>
<p>The DAO pattern provides a simple, consistent API for data access that does not require knowledge of an ORM interface. DAO does not just apply to simple mappings of one object to one relational table, but also allows complex queries to be performed and allows for stored procedures and database views to be mapped into data structures.</p>
<p>A typical DAO design pattern interface is shown below:</p>
<pre>class Project_Dao_Db_User extends Zf_Db_Adapter
{
    public function find($id)
    {
        $db = $this-&gt;getConnection();
        $query = $db-&gt;select()-&gt;from('user')-&gt;where('id = ?', $id);
        return $db-&gt;fetchRow($query);
    }

    public function findAll()
    {
        $db = $this-&gt;getConnection();
        $query = $db-&gt;select()-&gt;from('user');
        return $db-&gt;fetchAll($query);
    }

    public function insert($data)
    {
        $db = $this-&gt;getConnection();
        $db-&gt;insert('user', $data);
        return $db-&gt;lastInsertId();
    }

    public function update($id, $data)
    {
        $db = $this-&gt;getConnection();
        $where = $db-&gt;quoteInto('id = ?', $id);
        return $db-&gt;update('user', $data, $where);
    }

    public function delete($id)
    {
        $db = $this-&gt;getConnection();
        $where = $db-&gt;quoteInto('id = ?', $id);
        return $db-&gt;delete('user', $where);
    }
}</pre>
<p>Source Code: <a href="http://svn.fedecarg.com/repo/Zf/Db/Adapter.php" target="_blank">Zf_Db_Adapter</a></p>
<h3>The User Entity</h3>
<p>An Entity is anything that has continuity through a life cycle and distinctions independent of attributes that are important to the application&#8217;s user.</p>
<pre>class Project_Entity_User extends Zf_Domain_Entity
{
    public $id;
    public $firstName;
    public $lastName;
}</pre>
<p>Source Code: <a href="http://svn.fedecarg.com/repo/Zf/Domain/Entity.php" target="_blank">Zf_Domain_Entity</a></p>
<h3>The User DataMapper</h3>
<pre>class Project_DataMapper_User extends Zf_DataSource_Dao_Mapper
{
    protected $_map = array(
        'id'         =&gt; 'id',
        'first_name' =&gt; 'firstName',
        'last_name'  =&gt; 'lastName'
    );

    public function find($id)
    {
        $dao = new Project_Dao_Db_User();
        $row = $dao-&gt;find($id);
        if (!$row) {
            return false;
        }
        return $this-&gt;map($row);
    }
}</pre>
<p>Source Code: <a href="http://svn.fedecarg.com/repo/Zf/DataSource/Dao/Mapper.php" target="_blank">Zf_DataSource_Dao_Mapper</a></p>
<h3>The User Model</h3>
<p>The following class represents the User Relational Model:</p>
<pre>class Project_Model_User
{
    public function getUser($id)
    {
        $mapper = new Project_DataMapper_User();
        $mapper-&gt;setEntity(new Project_Entity_User());
        $user = $mapper-&gt;find($id);

        return $user;
    }
}</pre>
<h3>The User Controller</h3>
<pre>class UserController extends Zend_Controller_Action
{
    public function viewAction()
    {
        $model = new Project_Model_User();
        $user = $model-&gt;getUser($this-&gt;_getParam('id'));
        if ($user) {
            $userId = $user-&gt;getId();
            $userFirstName = $user-&gt;getFirstName();
            $userLastName = $user-&gt;getLastName();

            // get an array of database fields and values
            $row = $user-&gt;getRow();
        }
    }
}</pre>
<p>Keep in mind that ORM tools such as <a href="http://phpdatamapper.com/" target="_blank">phpDataMapper</a> and <a href="http://www.doctrine-project.org/" target="_blank">Doctrine</a> offer an alternative way of modeling data. ORMs and ERMs are popular with Web frameworks, and the combination of an ORM and DDD makes DAOs redundant, however, it has not been proven to be better than a straightforward approach of implementing a collection of domain-specific data access functions.</p>
<p>That&#8217;s all, I hope you&#8217;ve found this post useful.</p>
<br />Posted in Databases, Design Patterns, Frameworks, Programming, Software Architecture  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1713/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1713/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1713/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1713&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/09/19/zend-framework-dal-daos-and-datamappers/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
		<item>
		<title>Increase speed and reduce bandwidth usage with ZF and Apache</title>
		<link>http://blog.fedecarg.com/2009/07/06/increase-speed-and-reduce-bandwidth-usage-with-zf-and-apache/</link>
		<comments>http://blog.fedecarg.com/2009/07/06/increase-speed-and-reduce-bandwidth-usage-with-zf-and-apache/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 11:09:33 +0000</pubDate>
		<dc:creator>Federico</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open-source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1700</guid>
		<description><![CDATA[Apache&#8217;s mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
There are two ways of enabling gzip compression:

Using Apache&#8217;s mod_deflate
Using PHP&#8217;s built-in functions

Encoding the output and setting the appropriate headers manually makes the code more portable. Keep in mind that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1700&subd=phpimpact&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Apache&#8217;s mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.</p>
<p>There are two ways of enabling gzip compression:</p>
<ol>
<li>Using Apache&#8217;s mod_deflate</li>
<li>Using PHP&#8217;s built-in functions</li>
</ol>
<p>Encoding the output and setting the appropriate headers manually makes the code more portable. Keep in mind that there are hundreds of Linux distributions, each slightly different to significantly different. To allow portability the application should not make assumptions about the OS or config involved.</p>
<h3>Using Apache</h3>
<p><strong>1. Enable mod_deflate</strong></p>
<p>Debian/Ubuntu:</p>
<pre>$ a2enmod deflate
$ /etc/init.d/apache2 force-reload</pre>
<p><strong>2. Configure mode_deflate</strong></p>
<pre>$ nano /etc/apache2/mods-enabled/deflate.conf

#
# mod_deflate configuration
#
&lt;IfModule mod_deflate.c&gt;
 AddOutputFilterByType DEFLATE text/plain
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/xml
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/x-javascript

 DeflateCompressionLevel 9

 BrowserMatch ^Mozilla/4 gzip-only-text/html
 BrowserMatch ^Mozilla/4\.0[678] no-gzip
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

 DeflateFilterNote Input instream
 DeflateFilterNote Output outstream
 DeflateFilterNote Ratio ratio
&lt;/IfModule&gt;</pre>
<h3>Using PHP</h3>
<p><span>Create a gzip compressed string in </span>your bootstrap file:</p>
<pre>try {
    $frontController = Zend_Controller_Front::getInstance();
    if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
        ob_start();
        $frontController-&gt;dispatch();
        $output = gzencode(ob_get_contents(), 9);
        ob_end_clean();
        header('Content-Encoding: gzip');
        echo $output;
    } else {
        $frontController-&gt;dispatch();
    }
} catch (Exeption $e) {
    if (Zend_Registry::isRegistered('Zend_Log')) {
        Zend_Registry::get('Zend_Log')-&gt;err($e-&gt;getMessage());
    }
    $message = $e-&gt;getMessage() . "\n\n" . $e-&gt;getTraceAsString();
    /* trigger event */
}</pre>
<h3>Reference</h3>
<p><a href="http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/" target="_blank">Use mod_deflate to compress Web content delivered by Apache</a></p>
<br />Posted in Frameworks, Linux, Open-source, PHP, Programming  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpimpact.wordpress.com/1700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpimpact.wordpress.com/1700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpimpact.wordpress.com/1700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpimpact.wordpress.com/1700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpimpact.wordpress.com/1700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpimpact.wordpress.com/1700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpimpact.wordpress.com/1700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpimpact.wordpress.com/1700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpimpact.wordpress.com/1700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpimpact.wordpress.com/1700/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fedecarg.com&blog=920807&post=1700&subd=phpimpact&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.fedecarg.com/2009/07/06/increase-speed-and-reduce-bandwidth-usage-with-zf-and-apache/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8d6b74fce406b08bb28806ce7377e61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">phpimpact</media:title>
		</media:content>
	</item>
	</channel>
</rss>