<?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; Zend Framework</title>
	<atom:link href="http://www.logaholic.de/category/php/zend-framework-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>How to add transparent SoapHeader authentication as decorator to any existing service class</title>
		<link>http://www.logaholic.de/2011/12/09/how-to-add-transparent-soapheader-authentication-as-decorator-to-any-existing-service-class/</link>
		<comments>http://www.logaholic.de/2011/12/09/how-to-add-transparent-soapheader-authentication-as-decorator-to-any-existing-service-class/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 13:47:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=443</guid>
		<description><![CDATA[This should not be limited to it, but I&#8217;d like to show how I implemented this inside the Zend Framework and its Zend_Soap_* components.
SoapHeader authentication is a widely used method to secure access to soap Webservices where the credentials are in the request header.
Activating this type of authentication is for me down to a change [...]


Related posts:<ol><li><a href='http://www.logaholic.de/2011/08/18/php-5-3-1-and-soapheader-on-windows-getting-ignored/' rel='bookmark' title='Permanent Link: PHP 5.3.1 and SoapHeader on windows getting ignored'>PHP 5.3.1 and SoapHeader on windows getting ignored</a></li><li><a href='http://www.logaholic.de/2009/05/11/improving-http-authentication/' rel='bookmark' title='Permanent Link: Improving HTTP Authentication'>Improving HTTP Authentication</a></li><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></ol>]]></description>
			<content:encoded><![CDATA[<p>This should not be limited to it, but I&#8217;d like to show how I implemented this inside the Zend Framework and its Zend_Soap_* components.</p>
<p>SoapHeader authentication is a widely used method to secure access to soap Webservices where the credentials are in the request header.</p>
<p><strong>Activating this type of authentication is for me down to a change from this:</strong></p>
<pre class="brush: php; auto-links: false; gutter: false; html-script: false; ruler: false;">
$soap = new Zend_Soap_Server($uri.'&amp;wsdl', $serverOptions);
$soap-&gt;setClass('My_Service_'.$serviceName);
</pre>
<p><strong>to this:</strong></p>
<pre class="brush: php; auto-links: false; gutter: false; html-script: false; ruler: false;">
$soap = new Zend_Soap_Server($uri.'&amp;wsdl', $serverOptions);
$soap-&gt;setClass('My_Soap_Decorator_Secure', 'My_Service_'.$serviceName);
</pre>
<p><strong>This is the basic decorator code:</strong></p>
<pre class="brush: php; auto-links: false; gutter: false; html-script: false; ruler: false;">
/**
 * This class decorates Soap service classes, provides and enforces authentication via soap header 'authenticate'
 *
 * @author Karsten Deubert &lt;karsten@deubert.net&gt;
 */
class My_Soap_Decorator_Secure
{
    /**
     * @var bool
     */
    protected $_authenticationHeaderPresent = false;

    /**
     * @var mixed
     */
    protected $_authenticatedUser = null;

    /**
     * @var mixed
     */
    protected $_serviceClass = null;

    public function __construct($class)
    {
        if (!class_exists($class))
        {
            throw new Exception('invalid class: '.$class);
        }
        $this-&gt;_serviceClass = new $class();
    }

    /**
     * @param mixed $data
     * @return void
     */
    public function authenticate($data)
    {
        $this-&gt;_authenticationHeaderPresent = true;

        // authentication code which checks if credentials are valid

        $this-&gt;_authenticatedUser = $yourAuthenticatedUser;
    }

    public function __call($name, $arguments)
    {
        if (!$this-&gt;isAuthenticationHeaderPresent() || is_null($this-&gt;_authenticatedUser))
        {
            throw new Exception('authentication failed');
        }
        if (!is_callable(array($this-&gt;_serviceClass, $name)))
        {
            throw new Exception('invalid service class method');
        }

        return call_user_func_array(array($this-&gt;_serviceClass, $name), $arguments);
    }
}
</pre>
<p><strong>The usual soap request with authentication header should now look like this:</strong></p>
<pre class="brush: php; auto-links: false; gutter: false; html-script: false; ruler: false;">
$authData = new stdClass();
$authData-&gt;user = 'foo';
$authData-&gt;secret = 'bar';

$authHeader = new SoapHeader($namespace, 'authenticate', $authData);

$soapClient = new SoapClient('http://foo.bar/asdf?wsdl',
    array(
        'cache_wsdl' =&gt; 0,
        'soap_version' =&gt; SOAP_1_1
    )
);
$soapClient-&gt;__setSoapHeaders(array($authHeader));
$soapClient-&gt;fooMethod();
</pre>
<p>With this header the soap server will first execute the authenticate method from the decorator, then (if successful) pass the method call via magic __call to the inner service class and its fooMethod() in this example.</p>
<p>Voila, transparent SoapHeader authentication separated from your service classes <img src='http://www.logaholic.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>What I haven&#8217;t researched fully yet is if there is a way to specify the authenticate header in the WSDL &#8211; every comment appreciated.</p>


<p>Related posts:<ol><li><a href='http://www.logaholic.de/2011/08/18/php-5-3-1-and-soapheader-on-windows-getting-ignored/' rel='bookmark' title='Permanent Link: PHP 5.3.1 and SoapHeader on windows getting ignored'>PHP 5.3.1 and SoapHeader on windows getting ignored</a></li><li><a href='http://www.logaholic.de/2009/05/11/improving-http-authentication/' rel='bookmark' title='Permanent Link: Improving HTTP Authentication'>Improving HTTP Authentication</a></li><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></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2011/12/09/how-to-add-transparent-soapheader-authentication-as-decorator-to-any-existing-service-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Studio 7 and Zend Framework 1.9.0 released</title>
		<link>http://www.logaholic.de/2009/08/01/zend-studio-7-and-zend-framework-1-9-0-released/</link>
		<comments>http://www.logaholic.de/2009/08/01/zend-studio-7-and-zend-framework-1-9-0-released/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 10:00:13 +0000</pubDate>
		<dc:creator>Karsten Deubert</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Zend Studio]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=384</guid>
		<description><![CDATA[Zend Studio 7.0 brings a host of new features and enhancements that will help you develop faster, resolve defects more quickly, and take advantage of the latest PHP technologies directly from your development environment.
With full support for PHP 5.3, greatly enhanced source code editing, easy debugging through  integration with Zend Server, code generation through integration [...]


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/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><li><a href='http://www.logaholic.de/2009/05/05/review-lightweight-php5-oop-mvc-framework-simples-by-daniel-smacks-harrington/' rel='bookmark' title='Permanent Link: Review: Lightweight PHP5 OOP MVC framework &#8220;simples&#8221; by Daniel &#8217;smacks&#8217; Harrington'>Review: Lightweight PHP5 OOP MVC framework &#8220;simples&#8221; by Daniel &#8217;smacks&#8217; Harrington</a></li></ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p>Zend Studio 7.0 brings a host of new features and enhancements that will help you develop faster, resolve defects more quickly, and take advantage of the latest PHP technologies directly from your development environment.</p>
<p>With full support for<span style="font-weight: bold;"> PHP 5.3</span>, greatly enhanced source code editing, <span style="font-weight: bold;">easy debugging</span> through  integration with <span style="font-weight: bold;">Zend Server</span>, <span style="font-weight: bold;">code generation</span> through integration with <span style="font-weight: bold;">Zend Framework</span>, and improved performance, Zend Studio maintains its position as the leading solution for professional PHP developers.</p></blockquote>
<p><a title="Zend Studio" href="http://www.zend.com/en/products/studio/" target="_blank">Zend Studio</a></p>
<blockquote><p><span style="font-weight: bold;">New features in Zend Framework 1.9:</span></p>
<ul>
<li>Complete support for PHP 5.3 as well as 5.2 means developers can use the latest PHP language features in their Zend Framework-based apps</li>
<li>RESTful web services: now made easier through automated routing/detection</li>
<li>Message queues: useful for offload processing (credit card transactions, media uploads), cross-platform communication, user messaging features, and more.</li>
<li>LDAP: Microsoft ActiveDirectory &amp; Novell, plus searching, filtering, and tree features</li>
<li>RSS &amp; Atom: consume these popular feed formats using a common API and higher performance cached HTTP</li>
<li>DBUnit support: DBUnit’s test data setup and teardown make unit testing Zend Framework applications much easier</li>
</ul>
</blockquote>
<p><a title="Zend Framework 1.9 Features PHP 5.3 Readiness and New Professional Components" href="http://www.zend.com/en/company/news/Press/zend-framework-features-php-readiness-and-new-professional-components" target="_blank">Zend Framework 1.9 Features PHP 5.3 Readiness and New Professional Components</a></p>
<p>Downloads are running, Testsuites will show if ZF 1.9 breaks anything, and I will take the opportunity to fix some plugin issues with Zend Studio while upgrading <img src='http://www.logaholic.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>


<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/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><li><a href='http://www.logaholic.de/2009/05/05/review-lightweight-php5-oop-mvc-framework-simples-by-daniel-smacks-harrington/' rel='bookmark' title='Permanent Link: Review: Lightweight PHP5 OOP MVC framework &#8220;simples&#8221; by Daniel &#8217;smacks&#8217; Harrington'>Review: Lightweight PHP5 OOP MVC framework &#8220;simples&#8221; by Daniel &#8217;smacks&#8217; Harrington</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2009/08/01/zend-studio-7-and-zend-framework-1-9-0-released/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Zend Framework 1.8.0 released</title>
		<link>http://www.logaholic.de/2009/05/01/zend-framework-1-8-0-released/</link>
		<comments>http://www.logaholic.de/2009/05/01/zend-framework-1-8-0-released/#comments</comments>
		<pubDate>Fri, 01 May 2009 10:43:05 +0000</pubDate>
		<dc:creator>Karsten Deubert</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Stream Wrapper]]></category>
		<category><![CDATA[Zend_Service_Amazon_EC2]]></category>
		<category><![CDATA[Zend_Service_Amazon_S3]]></category>
		<category><![CDATA[Zend_Tool]]></category>

		<guid isPermaLink="false">http://www.logaholic.de/?p=143</guid>
		<description><![CDATA[&#8220;I&#8217;m pleased to announce the Zend Framework 1.8.0 release, the first in our     1.8 series of releases. This release marks the culmination of several     long-standing projects, as well as a formalization of many of our     recommended practices.       [...]


Related posts:<ol><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/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><li><a href='http://www.logaholic.de/2011/12/09/how-to-add-transparent-soapheader-authentication-as-decorator-to-any-existing-service-class/' rel='bookmark' title='Permanent Link: How to add transparent SoapHeader authentication as decorator to any existing service class'>How to add transparent SoapHeader authentication as decorator to any existing service class</a></li></ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>&#8220;I&#8217;m pleased to announce the Zend Framework 1.8.0 release, the first in our     1.8 series of releases. This release marks the culmination of several     long-standing projects, as well as a formalization of many of our     recommended practices.          There are two major stories in this release: first, the addition of several     components designed to provide and promote Rapid Application Development;     second, two offerings that make using Zend Framework in the cloud easier.&#8221; </em>[1]<em><br />
</em></p></blockquote>
<p>Some thoughts, in no particular order:</p>
<p>If you know <a title="Amazon S3" href="http://aws.amazon.com/s3/" target="_blank">Amazon S3 (Amazon Simple Storage Soluation, a web-service for storing and receiving files, scalable, fast, safe)</a> then you should have a look at <a title="Zend_Service_Amazon_S3" href="http://framework.zend.com/manual/en/zend.service.amazon.s3.html" target="_blank">Zend_Service_Amazon_S3</a>. The Zend Framework not only offers a nice object oriented implementation, but also provides a PHP Stream Wrapper. Why is this so nice? Because one could add Amazon S3 support to existing applications by simply prefixing any standard file-operation with &#8217;s3://&#8217;. This is the code sample from the documentation:</p>
<pre class="brush: php;">
&lt;?php
require_once 'Zend/Service/Amazon/S3.php';

$s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);

$s3-&gt;registerStreamWrapper(&quot;s3&quot;);

mkdir(&quot;s3://my-own-bucket&quot;);
file_put_contents(&quot;s3://my-own-bucket/testdata&quot;, &quot;mydata&quot;);

echo file_get_contents(&quot;s3://my-own-bucket/testdata&quot;);
</pre>
<p>Support for <a title="Amazon EC2" href="http://aws.amazon.com/ec2/" target="_blank">Amazon EC2 (Amazon Elastic Comput Cloud)</a> has also been added (<a title="Zend_Service_Amazon_Ec2" href="http://framework.zend.com/manual/en/zend.service.amazon.ec2.html" target="_blank">Zend_Service_Amazon_Ec2</a>).</p>
<blockquote><p><em>&#8220;Amazon EC2 provides a web service to allow launching and managing server     instances within Amazon&#8217;s data centers. These server instances may be used     at any time for any length of time &#8212; allowing you to scale your site only     when you need to handle extra traffic, or run your services entirely from     the EC2 platform.&#8221; </em>[1]</p></blockquote>
<p>Zend Framework jumped the train for &#8220;the&#8221; cli interface to the framework via <a title="Zend_Tool" href="http://framework.zend.com/manual/en/zend.tool.framework.html" target="_blank">Zend_Tool</a>. One could create whole projects, models, controllers, views with it. This makes sense for starters imho. My full featured Zend Studio for Eclipse with customized code templates does this job way better for me. One thing i miss (Agavi has it! ^^) is a phpunit interface and some configuration which tests should be run. In my opinion, just the existance of such an option would encourage more users to think about/actually use unit tests.</p>
<p><a title="Zend_Controller_Router" href="http://framework.zend.com/manual/en/zend.controller.router.html" target="_blank">Routing</a> now supports translation aware routes, and route chaining capabilites. Those are fetures i know and love from Agavi.</p>
<p>There are loads of other new features (see [1]), which I haven&#8217;t checked yet &#8211; sometimes simply because they didn&#8217;t interest me.</p>
<p>I&#8217;m curious if switching our main project on monday to ZF 1.8.0 will break any test ^^.</p>
<p><strong>Sources:</strong><br />
[1] <a title="Zend Developer Zone: Zend Framework 1.8.0 Released" href="http://devzone.zend.com/article/4524-Zend-Framework-1.8.0-Released" target="_blank">Zend Developer Zone: Zend Framework 1.8.0 Released</a></p>


<p>Related posts:<ol><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/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><li><a href='http://www.logaholic.de/2011/12/09/how-to-add-transparent-soapheader-authentication-as-decorator-to-any-existing-service-class/' rel='bookmark' title='Permanent Link: How to add transparent SoapHeader authentication as decorator to any existing service class'>How to add transparent SoapHeader authentication as decorator to any existing service class</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.logaholic.de/2009/05/01/zend-framework-1-8-0-released/feed/</wfw:commentRss>
		<slash:comments>2</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>
	</channel>
</rss>

