<?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/"
	>

<channel>
	<title>Logaholic.de &#187; Agavi</title>
	<atom:link href="http://www.logaholic.de/category/php/agavi-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logaholic.de</link>
	<description>queer as code!</description>
	<lastBuildDate>Fri, 09 Dec 2011 13:47:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Agavi chapter in the book &#8220;Quality Assurance in PHP Projects&#8221;</title>
		<link>http://www.logaholic.de/2009/04/25/agavi-chapter-in-the-book-quality-assurance-in-php-projects/</link>
		<comments>http://www.logaholic.de/2009/04/25/agavi-chapter-in-the-book-quality-assurance-in-php-projects/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 13:03:14 +0000</pubDate>
		<dc:creator>Karsten Deubert</dc:creator>
				<category><![CDATA[Agavi]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[Quality Assurance]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=100</guid>
		<description><![CDATA[Later this year, there will be a book on &#8220;Quality Assurance in PHP Projects&#8221; by Sebastian Bergmann (the author of PHPUnit) and Stefan Priebsch. Their own teaser:
&#8220;Stefan Priebsch and myself, Sebastian Bergmann, are writing a book on &#8220;Quality Assurance in PHP Projects&#8221;. The book will be published in English and German at the same time [...]


Related posts:<ol><li><a href='http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/' rel='bookmark' title='Permanent Link: How we use Event Driven Development in an Agavi project'>How we use Event Driven Development in an Agavi project</a></li><li><a href='http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/' rel='bookmark' title='Permanent Link: Agavi vs Zend Framework Part 1 &#8211; Forms'>Agavi vs Zend Framework Part 1 &#8211; Forms</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Later this year, there will be a book on &#8220;<a title="Quality Assurance in PHP Projects" href="http://qualityassuranceinphpprojects.com/" target="_blank">Quality Assurance in PHP Projects</a>&#8221; by <a title="Sebastian Bergmann" href="http://sebastian-bergmann.de/" target="_blank">Sebastian Bergmann</a> (the author of <a title="phpunit" href="http://www.phpunit.de/" target="_blank">PHPUnit</a>) and <a title="Stefan Priebsch" href="http://www.priebsch.de/" target="_blank">Stefan Priebsch</a>. Their own teaser:</p>
<blockquote><p><em>&#8220;Stefan Priebsch and myself, Sebastian Bergmann, are writing a book on &#8220;Quality Assurance in PHP Projects&#8221;. The book will be published in English and German at the same time later this year.<br />
The idea for the book is that Stefan Priebsch and I write the introductory as well as the concluding chapters while other authors contribute case studies for the middle part of the book.&#8221;</em></p>
<p><small>Source: <a title="Quality Assurance in PHP Projects - Introduction" href="http://qualityassuranceinphpprojects.com/archives/1-Introduction.html" target="_blank">Quality Assurance in PHP Projects &#8211; Introduction</a></small></p></blockquote>
<p>As I just discovered, one case study in this book is about <a title="Agavi" href="http://www.agavi.org/" target="_blank">Agavi</a>, contributed by David Zülke. There is also an abstract for this chapter: <a title="Testing Agavi: Why Test Isolation Matters" href="http://qualityassuranceinphpprojects.com/archives/9-Testing-Agavi-Why-Test-Isolation-Matters.html" target="_blank">&#8220;Testing Agavi: Why Test Isolation Matters&#8221;</a>.</p>
<p>I&#8217;m looking forward to this book: interesting topic(s), interesting case studies.</p>


<p>Related posts:<ol><li><a href='http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/' rel='bookmark' title='Permanent Link: How we use Event Driven Development in an Agavi project'>How we use Event Driven Development in an Agavi project</a></li><li><a href='http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/' rel='bookmark' title='Permanent Link: Agavi vs Zend Framework Part 1 &#8211; Forms'>Agavi vs Zend Framework Part 1 &#8211; Forms</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2009/04/25/agavi-chapter-in-the-book-quality-assurance-in-php-projects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Agavi vs Zend Framework Part 1 &#8211; Forms</title>
		<link>http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/</link>
		<comments>http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 11:38:30 +0000</pubDate>
		<dc:creator>Karsten Deubert</dc:creator>
				<category><![CDATA[Agavi]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[AgaviFormPopulationFilter]]></category>
		<category><![CDATA[DRY]]></category>
		<category><![CDATA[Encapsulation]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=64</guid>
		<description><![CDATA[Agavi and Zend Framework are two major MVC PHP5 Frameworks today. I am actively using both in two different projects.
I will discuss some differences, starting with Part 1 now: Forms.
Forms are used in nearly any web application where you expect user-input. Following the &#8220;never trust your users&#8221; rule, proper validation is one major (security-) subtopic [...]


Related posts:<ol><li><a href='http://www.logaholic.de/2009/05/01/zend-framework-1-8-0-released/' rel='bookmark' title='Permanent Link: Zend Framework 1.8.0 released'>Zend Framework 1.8.0 released</a></li><li><a href='http://www.logaholic.de/2009/08/01/zend-studio-7-and-zend-framework-1-9-0-released/' rel='bookmark' title='Permanent Link: Zend Studio 7 and Zend Framework 1.9.0 released'>Zend Studio 7 and Zend Framework 1.9.0 released</a></li><li><a href='http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/' rel='bookmark' title='Permanent Link: How we use Event Driven Development in an Agavi project'>How we use Event Driven Development in an Agavi project</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><a title="Agavi" href="http://www.agavi.org/" target="_blank">Agavi</a> and <a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> are two major MVC PHP5 Frameworks today. I am actively using both in two different projects.</p>
<p>I will discuss some differences, starting with Part 1 now: <strong>Forms</strong>.</p>
<p>Forms are used in nearly any web application where you expect user-input. Following the <em>&#8220;never trust your users&#8221;</em> rule, proper validation is one major (security-) subtopic of forms.</p>
<h3>1. Building simple Forms:</h3>
<h4><strong>Zend Framework:</strong></h4>
<p>a) define your Zend_Form object, once, including validation</p>
<pre class="brush: php;">
    /**
     * @return Zend_Form
     */
    protected function getDemoForm()
    {
        $form = new Zend_Form();

        $form-&gt;addElement('textarea', 'comment', array(
            'label' =&gt; 'comment:',
            'required' =&gt; true,
            'validators' =&gt; array(
                array('StringLength', array(160), array(1))
            )
        ));
        $form-&gt;addElement('submit', 'submit', array(
            'label' =&gt; 'submit',
        ));

        return $form;
    }
</pre>
<p>b) trigger validation in your action, use the result if validation succeeds</p>
<pre class="brush: php;">
$demoForm = $this-&gt;getDemoForm();
$request = $this-&gt;getRequest();

if ($request-&gt;isPost())
{
    if ($demoForm&gt;isValid($request-&gt;getPost()))
    {
        doSomeStuff();
        redirectToSuccessAction();
    }
}
</pre>
<p>c) pass the form object to your view</p>
<pre class="brush: php;">$this-&gt;view-&gt;demoForm = $demoForm;</pre>
<h4>Agavi:</h4>
<p>a) write html code for your form in your view</p>
<p>You know how that works. (Or see the Agavi documentation link below)</p>
<p>b) add validation to your write-<em>action</em></p>
<p>The Agavi documentation prefers defining validators in a .xml file, per action, app/modules/Posts/validate/Add.xml:  (module Post, Action Add)</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;ae:configurations
  xmlns=&quot;http://agavi.org/agavi/config/parts/validators/1.0&quot;
  xmlns:ae=&quot;http://agavi.org/agavi/config/global/envelope/1.0&quot;
  parent=&quot;%core.module_dir%/Posts/config/validators.xml&quot;
&gt;
  &lt;ae:configuration&gt;

    &lt;validators&gt;
      &lt;validator class=&quot;string&quot;&gt;
        &lt;arguments&gt;
          &lt;argument&gt;title&lt;/argument&gt;
        &lt;/arguments&gt;
        &lt;errors&gt;
          &lt;error&gt;The title field has an invalid value.&lt;/error&gt;
          &lt;error for=&quot;required&quot;&gt;Please provide a title.&lt;/error&gt;
          &lt;error for=&quot;max_error&quot;&gt;The title must be shorter than 255 characters.&lt;/error&gt;
        &lt;/errors&gt;
        &lt;ae:parameters&gt;
          &lt;ae:parameter name=&quot;max&quot;&gt;255&lt;/ae:parameter&gt;
        &lt;/ae:parameters&gt;
      &lt;/validator&gt;
    &lt;/validators&gt;
  &lt;/ae:configuration&gt;
&lt;/ae:configurations&gt;
</pre>
<p>c) formpopulationfilter magic</p>
<blockquote><p>&#8220;All we need to do is re-display our form on the     error page and the <span class="apiname">AgaviFormPopulationFilter</span> will     perform all of those duties. To re-display the form we could either     include it in the ErrorViews template or we could set the input template     in the view.&#8221;</p></blockquote>
<h3>2. The Zend Framework way</h3>
<p>+ Encapsulation</p>
<p>+ Abstraction</p>
<p>+ DRY</p>
<h3>3. The Agavi way</h3>
<p>- I have to keep an eye to input names, as they are needed at more than one place. Beware of templating guys changing the input names, breaking stuff.</p>
<p>- validating an action, not a single form/form object</p>
<p>- breaks the DRY principle, code duplication occurs</p>
<h3>4. Conclusion</h3>
<p>I prefer <strong>Zend Framework</strong> over Agavi for forms. The main reason is the encapsulation in ZF with the Zend_Form object.</p>
<p>I can have more separated forms with separate validation on one page. I can reuse forms withouth having (that much) duplicate code anywhere. I don&#8217;t have to make changes to multiple locations if changing input names or validation, just one object holds every needed information/configuration. Zend_Form also does the html output for me, application-persistent interface guaranteed (styling is done via css or decorators per form/element).</p>
<p><strong>Sources:</strong></p>
<ul>
<li><a title="Zend Framework Documentation: Zend_Form" href="http://framework.zend.com/manual/en/zend.form.html" target="_blank">Zend Framework Documentation: Zend_Form</a></li>
<li><a title="Agavi Documentation: Form Processing" href="http://www.agavi.org/documentation/tutorial/step7/introduction.html" target="_blank">Agavi Documentation: Form Processing</a></li>
</ul>


<p>Related posts:<ol><li><a href='http://www.logaholic.de/2009/05/01/zend-framework-1-8-0-released/' rel='bookmark' title='Permanent Link: Zend Framework 1.8.0 released'>Zend Framework 1.8.0 released</a></li><li><a href='http://www.logaholic.de/2009/08/01/zend-studio-7-and-zend-framework-1-9-0-released/' rel='bookmark' title='Permanent Link: Zend Studio 7 and Zend Framework 1.9.0 released'>Zend Studio 7 and Zend Framework 1.9.0 released</a></li><li><a href='http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/' rel='bookmark' title='Permanent Link: How we use Event Driven Development in an Agavi project'>How we use Event Driven Development in an Agavi project</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How we use Event Driven Development in an Agavi project</title>
		<link>http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/</link>
		<comments>http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 19:54:21 +0000</pubDate>
		<dc:creator>Karsten Deubert</dc:creator>
				<category><![CDATA[Agavi]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Event Driven Development]]></category>
		<category><![CDATA[Observer Pattern]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=44</guid>
		<description><![CDATA[We used the observer pattern to write our own EventObserver, which enables us to use Event Driven Development in an Agavi project.
Since we are working module-based, there are two simple steps to add an Event listener for your module to the system.
1. Add %module_dir%/config/event_listeners.xml

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;config&#62;
    &#60;listeners&#62;
      [...]


Related posts:<ol><li><a href='http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/' rel='bookmark' title='Permanent Link: Agavi vs Zend Framework Part 1 &#8211; Forms'>Agavi vs Zend Framework Part 1 &#8211; Forms</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>We used the observer pattern to write our own EventObserver, which enables us to use Event Driven Development in an Agavi project.</p>
<p>Since we are working module-based, there are two simple steps to add an Event listener for your module to the system.</p>
<h3>1. Add %module_dir%/config/event_listeners.xml</h3>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;config&gt;
    &lt;listeners&gt;
        &lt;event&gt;
            &lt;name&gt;modules.forum.post.new&lt;/name&gt;
            &lt;callback&gt;Forum_DefaultListener&lt;/callback&gt;
        &lt;/event&gt;
    &lt;/listeners&gt;
&lt;/config&gt;
</pre>
<p>The &lt;name&gt; element holds the event name or &#8220;channel&#8221;, the &lt;callback&gt; element holds the name of the listener-class.</p>
<h3>2. Add %module_dir%/listeners/Forum_DefaultListener.class.php</h3>
<p><em>(Note: callback name goes here as you can see, for autoloading)</em></p>
<pre class="brush: php;">
class Forum_DefaultListener implements EventListenerInterface
{
    public static function listenToEvent(Event $event) {
        $name = $event-&gt;getName();
        switch($name) {
            case 'modules.forum.post.new':
                throw new HelloWorldException();
        }
    }
}
</pre>
<p>Listening to &#8216;modules.forum.post.new&#8217; events is working from this point <img src='http://www.logaholic.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Firing events is as easy as this, anywhere in your module-code:</h3>
<pre class="brush: php;">
EventObserver::getInstance()
    -&gt;notify(new Event('modules.forum.post.new', $message));
</pre>
<p>This call will find its way to the configured listener, Forum_DefaultListener, and Forum_DefaultListener::listenToEvent (like any other listener) will be called with an Event, including the passed $message object.</p>


<p>Related posts:<ol><li><a href='http://www.logaholic.de/2009/04/24/agavi-vs-zend-framework-part-1-forms/' rel='bookmark' title='Permanent Link: Agavi vs Zend Framework Part 1 &#8211; Forms'>Agavi vs Zend Framework Part 1 &#8211; Forms</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2009/04/23/event-driven-development-in-an-agavi-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

