<?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>bsagols&#039; blog</title>
	<atom:link href="http://bsagols.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bsagols.wordpress.com</link>
	<description>Just another WordPress.com site</description>
	<lastBuildDate>Fri, 10 Jun 2011 12:45:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bsagols.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>bsagols&#039; blog</title>
		<link>http://bsagols.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bsagols.wordpress.com/osd.xml" title="bsagols&#039; blog" />
	<atom:link rel='hub' href='http://bsagols.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Blog moved to bsagols.com/blog</title>
		<link>http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/</link>
		<comments>http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 11:02:18 +0000</pubDate>
		<dc:creator>bsagols</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bsagols.wordpress.com/?p=64</guid>
		<description><![CDATA[Hello all, If you land here, thanks to google mostly&#8230; Know that I&#8217;ve moved this blog under my personal domain: http://bsagols.com/blog/ I didn&#8217;t do the proper redirection &#8217;cause it costs 12 $ a year and I don&#8217;t see the point &#8230; <a href="http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=64&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>If you land here, thanks to google mostly&#8230; Know that I&#8217;ve moved this blog under my personal domain:</p>
<p><a title="bsagols blog" href="http://bsagols.com/blog/">http://bsagols.com/blog/</a></p>
<p>I didn&#8217;t do the proper redirection &#8217;cause it costs 12 $ a year and I don&#8217;t see the point paying for this (12 $ (a year !) to put 1 line in an .htaccess file ?!).</p>
<p>So please now follow this blog from the new address.</p>
<p>Cheers,</p>
<p>NB: I may trash this wordpress.com instance of the blog after a while&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bsagols.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bsagols.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bsagols.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=64&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2205033f2ad9b5931ee7eac7e46d1d54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bsagols</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework rewriting rules explained (.htaccess)</title>
		<link>http://bsagols.wordpress.com/2010/09/02/zend-framework-rewriting-rules-explained-htaccess/</link>
		<comments>http://bsagols.wordpress.com/2010/09/02/zend-framework-rewriting-rules-explained-htaccess/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 14:19:26 +0000</pubDate>
		<dc:creator>bsagols</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://bsagols.wordpress.com/?p=53</guid>
		<description><![CDATA[blog has moved I&#8217;ve moved my blog under my personal domain: http://bsagols.com/blog I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to &#8230; <a href="http://bsagols.wordpress.com/2010/09/02/zend-framework-rewriting-rules-explained-htaccess/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=53&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>blog has moved</h1>
<p>I&#8217;ve <a title="Blog moved to bsagols.com/blog" href="http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/">moved my blog</a> under my personal domain:</p>
<p><a title="bsagols blog" href="http://bsagols.com/blog/">http://bsagols.com/blog</a></p>
<p>I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 line in an .htaccess file ?!).</p>
<p>Here is the new URL of this post:</p>
<p><a title="bsagols blog - Zend Framework rewriting rules explained (.htaccess)" href="http://bsagols.com/blog/2010/09/02/zend-framework-rewriting-rules-explained-htaccess/">bsagols / blog - Zend Framework rewriting rules explained (.htaccess)</a></p>
<p>Here follows the original post&#8230;</p>
<p>- -</p>
<p>Sometimes (often ?!) you just copy / paste some code without taking time to deeply understand it&#8230; I use to do this when I&#8217;m running out of time (always ?!)&#8230;</p>
<p>This way of doing things is not perennial&#8230; At all. The day you will be stuck because you didn&#8217;t take that time, always comes.</p>
<p>This is what happened with the rewriting rules of a standard Zend Framework project, I just <a title="Rewriting rules of a standard ZF project" href="http://framework.zend.com/manual/en/project-structure.rewrite.html#project-structure.rewrite.apache.htaccess" target="_blank">copied / pasted them</a>.</p>
<p>It worked. Until the day I got stuck. I needed to understand why some requested files were passing though the rewriting logic when others weren&#8217;t.</p>
<p>Let&#8217;s shade some light on these rewriting rules:</p>
<pre>1. RewriteCond %{REQUEST_FILENAME} -s [OR]
2. RewriteCond %{REQUEST_FILENAME} -l [OR]
3. RewriteCond %{REQUEST_FILENAME} -d
4. RewriteRule ^.*$ - [NC,L]
5. RewriteRule ^.*$ index.php [NC,L]</pre>
<p>First, let&#8217;s see what the REQUEST_FILENAME variable is:</p>
<blockquote><p><code>REQUEST_FILENAME</code>The full local filesystem path to the file or script matching the request.</p></blockquote>
<p>Now let&#8217;s take the rewriting rules one by one.</p>
<pre>1. RewriteCond %{REQUEST_FILENAME} -s [OR]</pre>
<p><em>[ Source: <a title="Apache mod_rewrite module official documentation" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">mod_rewrite</a> ]</em></p>
<blockquote><p>&#8216;<strong>-s</strong>&#8216; (is regular file, with <strong>s</strong>ize)<br />
Treats the <em>TestString</em> as a pathname and tests whether or not it exists, and is a regular file with size greater than zero.</p></blockquote>
<p>So IF the requested file name is an existing non-empty file on the file system&#8230;</p>
<pre>2. RewriteCond %{REQUEST_FILENAME} -l [OR]</pre>
<p><em>[ Source: <a title="Apache mod_rewrite module  official documentation" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">mod_rewrite</a> ]</em></p>
<blockquote><p>&#8216;<strong>-l</strong>&#8216; (is symbolic <strong>l</strong>ink)<br />
Treats the <em>TestString</em> as a pathname and tests whether or not it exists, and is a symbolic link.</p></blockquote>
<p>OR is an existing symbolic link on the file system&#8230;</p>
<pre>3. RewriteCond %{REQUEST_FILENAME} -d</pre>
<p><em>[ Source: <a title="Apache mod_rewrite module  official documentation" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">mod_rewrite</a> ]</em></p>
<blockquote><p>&#8216;<strong>-d</strong>&#8216; (is <strong>d</strong>irectory)<br />
Treats the <em>TestString</em> as a pathname and tests whether or not it exists, and is a directory.</p></blockquote>
<p>OR is an existing directory on the file system&#8230;</p>
<pre>4. RewriteRule ^.*$ - [NC,L]</pre>
<p><strong>D</strong><strong>on&#8217;t rewrite anything !!</strong></p>
<p>Let&#8217;s take a closer look at that line. Why doesn&#8217;t it rewrite anything? Because of the special character &#8220;-&#8221; (dash):</p>
<p><em>[ Source: <a title="RewriteRule directive" href="http://www.helicontech.com/isapi_rewrite/doc/RewriteRule.htm" target="_blank">RewriteRule directive</a> ]</em></p>
<blockquote><p>Syntax: RewriteRule <em>Pattern <strong>Substitution </strong>[flags]</em></p>
<p><em>[ ... ]<br />
</em></p>
<p>Special string &#8216;-&#8217; (dash) in <strong><em>Substitution</em> </strong>means no substitution and is useful when you need to apply the rule while leaving original URL untouched.</p></blockquote>
<p>This is the behavior we are expecting. If a requested file name complies with one of the above rewrite conditions, we don&#8217;t want the rewrite process to occur.</p>
<p>This means that any file, symlink or directory that actually exists <strong>in the /public/ folder</strong> (root of the webapp&#8230;) will be served normally by the Apache server. For instance, all the static resources (css, js, etc&#8230;) are located in the /public/ folder&#8230;</p>
<p>In addition, the flags [L] indicate that this rewrite rule is the last one to be applied, none will occur after that one, if processed:</p>
<p><em>[ Source: <a title="Apache mod_rewrite module  official documentation" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">mod_rewrite</a> ]</em></p>
<blockquote><p>&#8216;<strong><code>last|L</code></strong>&#8216; (<strong>l</strong>ast rule)<br />
Stop the rewriting process here and don&#8217;t apply any more rewrite rules. This corresponds to the Perl <code>last</code> command or the <code>break</code> command in C. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL (&#8216;<code>/</code>&#8216;) to a real one, <em>e.g.</em>, &#8216;<code>/e/www/</code>&#8216;.</p></blockquote>
<p>So again, if that rule is processed, it will prevent the following ones in the .htaccess to occur&#8230; This flag is interesting in our case, because the following rewrite rule is very generic and we don&#8217;t want it to occur always:</p>
<pre>5. RewriteRule ^.*$ index.php [NC,L]</pre>
<p>This rule means rewrite / re-orient / re-map any request URI coming in (^.*$) to index.php. And as you may know the index.php contains the core logic of a standard Zend Framework MVC project.</p>
<p>Note: The flag [NC] means &#8220;no case&#8221;:</p>
<p><em>[ Source: <a title="Apache mod_rewrite module  official documentation" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">mod_rewrite</a> ]</em></p>
<blockquote><p>&#8216;<strong><code>nocase|NC</code></strong>&#8216; (<strong>n</strong>o <strong>c</strong>ase)<br />
This makes the <em>Pattern</em> case-insensitive, ignoring difference between &#8216;A-Z&#8217; and &#8216;a-z&#8217; when <em>Pattern</em> is matched against the current URL.</p></blockquote>
<p>So what&#8217;s important here, is that this last rule applies only if the one just above (line 4.) haven&#8217;t occured. Meaning that all the previous conditions (RewriteCond) only apply to the RewriteRule at line 4.</p>
<p>It allows the static resources to be served normally.</p>
<p>Hope that helps someone, somewhere.</p>
<p>PS: Understanding this was not much complicated than reading the <a title="official documentation of the mod_rewrite Apache module" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">official documentation of the mod_rewrite Apache module</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bsagols.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bsagols.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bsagols.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=53&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bsagols.wordpress.com/2010/09/02/zend-framework-rewriting-rules-explained-htaccess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2205033f2ad9b5931ee7eac7e46d1d54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bsagols</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend_Loader_Autoloader Stand-alone and Modular approaches</title>
		<link>http://bsagols.wordpress.com/2010/08/12/zend_loader_autoloader-stand-alone-and-modular-approaches/</link>
		<comments>http://bsagols.wordpress.com/2010/08/12/zend_loader_autoloader-stand-alone-and-modular-approaches/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 15:59:37 +0000</pubDate>
		<dc:creator>bsagols</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://bsagols.wordpress.com/?p=19</guid>
		<description><![CDATA[blog has moved I&#8217;ve moved my blog under my personal domain: http://bsagols.com/blog I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 &#8230; <a href="http://bsagols.wordpress.com/2010/08/12/zend_loader_autoloader-stand-alone-and-modular-approaches/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=19&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>blog has moved</h1>
<p>I&#8217;ve <a title="Blog moved to bsagols.com/blog" href="http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/">moved my blog</a> under my personal domain:</p>
<p><a title="bsagols blog" href="http://bsagols.com/blog/">http://bsagols.com/blog</a></p>
<p>I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 line in an .htaccess file ?!).</p>
<p>Here is the new URL of this post:</p>
<p><a title="bsagols blog - Zend_Loader_Autoloader Stand-alone and Modular approaches" href="http://bsagols.wordpress.com/2010/08/12/zend_loader_autoloader-stand-alone-and-modular-approaches/">bsagols / blog - Zend_Loader_Autoloader Stand-alone and Modular approaches</a></p>
<p>Here follows the original post&#8230;</p>
<p>- -</p>
<p>As I was desperately browsing the web for some information about how to configure the Zend_Loader_Autoloader in stand-alone mode, I found myself a bit confused about the different approaches of the Zend Autoloader.</p>
<p>I&#8217;ve identified 3 cases of using the Autoloader:</p>
<ol>
<li><strong>Stand-alone</strong>: Let&#8217;s say this is the case when you do not use the MVC model of the Zend Framework, but you need to load classes &#8220;on the fly&#8221;</li>
<li><strong>Non-modular </strong>ZF MVC application</li>
<li><strong>Modular </strong>ZF MVC application</li>
</ol>
<p>These are the 3 cases where the configuration of the Autoloader differs.</p>
<h1>Stand-alone</h1>
<p>This is the basic configuration of the Autoloader, the fundamental one. You need it to load any class dynamically <strong>as long as it is included in your include path</strong>.</p>
<p>First, the official Zend documentation is great:</p>
<p><a title="Zend Autoloader Usage" href="http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.usage" target="_blank">http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.usage</a></p>
<p>What&#8217;s important here: instantiating the Autoloader Singleton&#8230;</p>
<pre class="brush: php;">
Zend_Loader_Autoloader::getInstance();
</pre>
<p>&#8230; Does register 2 default namespaces:</p>
<ul>
<li>Zend_</li>
<li>ZendX_</li>
</ul>
<p>So you can load dynamically any class of the Zend library without any additional configuration.</p>
<p>If you wish to add other namespaces to be loaded dynamically, just register them:</p>
<pre class="brush: php;">
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader-&gt;registerNamespace('Foo_');
$autoloader-&gt;registerNamespace('Bar_');
...
</pre>
<p><strong>Alternatively </strong>(this is equivalent) you can configure this in your <strong>application.ini</strong> file (cleaner, in my opinion):</p>
<p><em>[ application.ini ]</em></p>
<pre>autoloadernamespaces[] = "Foo_"
autoloadernamespaces[] = "Bar_"
...</pre>
<h1>Non-modular ZF MVC application</h1>
<p>So now that I am able to load any class from my library folder, what about loading classes located in my application folder (models, mappers, forms, etc&#8230;) ?</p>
<p>If you follow the standard <a title="Non-modular structure of a ZF project" href="http://framework.zend.com/manual/en/learning.quickstart.create-project.html#learning.quickstart.create-project.create-project" target="_blank">non-modular structure of a ZF MVC project</a>, the Zend Framework comes with a solution for that. Instead of configuring the (Stand-alone) Autoloader with all these new namespaces:</p>
<ul>
<li>Model</li>
<li>Model_DbTable</li>
<li>Form_</li>
<li>etc&#8230;</li>
</ul>
<p>You can instantiate the <a title="Zend_Application_Module_Autoloader" href="http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html#zend.loader.autoloader-resource.module" target="_blank">Zend_Application_Module_Autoloader</a> which will configure / register automatically these namespaces for you.</p>
<p>Here the <a title="Autoloader Application Resource" href="http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html#zend.loader.autoloader-resource.module" target="_blank">official documentation</a> lacks of information, in my opinion&#8230; Or, at least, this is what I thought before finding another interesting section in the official Zend Framework documentation:</p>
<p><a title="Autoloading in zend Framework" href="http://framework.zend.com/manual/en/learning.autoloading.html" target="_blank">Autoloading in Zend Framework</a></p>
<p>And especialy that section, talking about the &#8220;Resource Autoloader&#8221;:</p>
<p><a title="Learning Autoloading resources" href="http://framework.zend.com/manual/en/learning.autoloading.resources.html#learning.autoloading.resources" target="_blank">http://framework.zend.com/manual/en/learning.autoloading.resources.html#learning.autoloading.resources</a></p>
<p>Zend_Application_<strong>Module_Autoloader </strong>will look for the standard &#8220;Resources&#8221; and configure the associated namespaces:</p>
<pre>RESOURCE         =&gt; NAMESPACE

forms/           =&gt; Form
models/          =&gt; Model
models/DbTable/  =&gt; Model_DbTable
models/mappers/  =&gt; Model_Mapper
plugins/         =&gt; Plugin
services/        =&gt; Service
views/helpers    =&gt; View_Helper
views/filters    =&gt; View_Filter</pre>
<p>Just specify the folder where to look for the standard &#8220;Resources&#8221; (here APPLICATION_PATH):</p>
<p><em>[ Bootstrap.php ]</em></p>
<pre class="brush: php;">
protected function _initAutoloader()
{
   new Zend_Application_Module_Autoloader(array(
      'namespace' =&gt; 'Application',
      'basePath'  =&gt; APPLICATION_PATH,
   ));
}
</pre>
<p><strong>Alternatively </strong>you can configure this in your <strong>application.ini</strong> file (this is completely equivalent as long as your Bootstrap.php file is under the APPLICATION_PATH folder):</p>
<p><em>[ application.ini ]</em></p>
<pre>appnamespace = "Application"</pre>
<p>Note: The &#8220;Application&#8221; namespace is recommended by the <a title="&quot;Application&quot; namespace" href="http://framework.zend.com/manual/en/learning.quickstart.create-model.html#learning.quickstart.create-model" target="_blank">official documentation of the Zend Framework</a>.</p>
<h2>Behind the scene (application.ini)</h2>
<p>The Bootstrap.php (Zend_Application_Bootstrap_Bootstrap) tries to launch an instance of Zend_Application_Module_Autoloader with the following options:</p>
<ul>
<li><strong>namespace </strong>is the property &#8220;appnamespace&#8221; of application.ini (getAppNamespace()&#8230;)</li>
</ul>
<ul>
<li><strong>basePath </strong>is under the folder where the Bootstrap.php file is located (dirname($path)&#8230;)</li>
</ul>
<p><em>[ Zend_Application_Bootstrap_Bootstrap ]</em></p>
<pre class="brush: php;">
/**
 * Retrieve module resource loader
 *
 * @return Zend_Loader_Autoloader_Resource
 */
 public function getResourceLoader()
 {
    if ((null === $this-&gt;_resourceLoader)
    &amp;&amp; (false !== ($namespace = $this-&gt;getAppNamespace()))
    ) {
       $r    = new ReflectionClass($this);
       $path = $r-&gt;getFileName();
       $this-&gt;setResourceLoader(new Zend_Application_Module_Autoloader(array(
          'namespace' =&gt; $namespace,
          'basePath'  =&gt; dirname($path),
       )));
    }
    return $this-&gt;_resourceLoader;
 }
</pre>
<h1>Modular ZF MVC application</h1>
<p>Configuring the Autoloader for a modular ZF MVC application is just about configuring each module Autoloader independently:</p>
<p><em>[ Bootstrap.php ]</em></p>
<pre class="brush: php;">
protected function _initAutoloader()
{
new Zend_Application_Module_Autoloader(array(
 'namespace' =&gt; 'Application',
 'basePath'  =&gt; APPLICATION_PATH . '/modules/default',
));
new Zend_Application_Module_Autoloader(array(
 'namespace' =&gt; 'Admin',
 'basePath'  =&gt; APPLICATION_PATH . '/modules/admin',
));
new Zend_Application_Module_Autoloader(array(
 'namespace' =&gt; 'Blog',
 'basePath'  =&gt; APPLICATION_PATH . '/modules/blog',
));
...
}
</pre>
<p><strong>Alternatively </strong>you can configure this in your <strong>application.ini</strong> file :</p>
<p><em>[ application.ini ]</em></p>
<pre>resources.modules[] =</pre>
<h2>Behind the scene (application.ini)</h2>
<p>It loads an instance of <a title="Zend_Application_Resource_Modules" href="http://framework.zend.com/manual/fr/zend.application.available-resources.html#zend.application.available-resources.modules" target="_blank">Zend_Application_Resource_Modules</a>. Behind the scene, this Application_Resource scans your modules folder, looking for modules.</p>
<p>Let&#8217;s say you have the following folder structure:</p>
<pre>application/
   modules/
      default/
      admin/
      blog/</pre>
<h3>1. Zend_Application_Resource_Modules looks for modules</h3>
<p>The Zend_Application_Resource_Modules will find 3 modules. For each folder / module, it will look for a Bootstrap.php file containing a _Bootstrap class and instanciate it. So let&#8217;s say:</p>
<pre>application/
   modules/
      default/
         Bootstrap.php   // Default_Bootstrap extends Zend_Application_Module_Bootstrap

      admin/
         Bootstrap.php   // Admin_Bootstrap extends Zend_Application_Module_Bootstrap

      blog/
         Bootstrap.php   // Blog_Bootstrap extends Zend_Application_Module_Bootstrap

   Bootstrap.php   // Bootstrap extends Zend_Application_Bootstrap_Bootstrap</pre>
<h3>2. Zend_Application_Module_Bootstrap configures the module Autoloader</h3>
<p>This is when instantiating &#8220;Default_Bootstrap&#8221; that the Autoloader of the &#8220;Default&#8221; module is loaded / configured (because it extends Zend_Application_Module_Bootstrap&#8230;).</p>
<p>By default, it uses the module name as the namespace for the module Autoloader:</p>
<p><em>[ Zend_Application_Module_Bootstrap ]</em></p>
<pre class="brush: php;">
/**
 * Get default application namespace
 *
 * Proxies to {@link getModuleName()}, and returns the current module
 * name
 *
 * @return string
 */
 public function getAppNamespace()
 {
    return $this-&gt;getModuleName();
 }
</pre>
<p>The module name being the prefix of the module Bootstrap classname:</p>
<p><em>[ Zend_Application_Module_Bootstrap ]</em></p>
<pre class="brush: php;">
 /**
 * Retrieve module name
 *
 * @return string
 */
 public function getModuleName()
 {
    if (empty($this-&gt;_moduleName)) {
       $class = get_class($this);
       if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) {
          $prefix = $matches[1];
       } else {
          $prefix = $class;
       }
       $this-&gt;_moduleName = $prefix;
    }
    return $this-&gt;_moduleName;
 }
</pre>
<p>For example, the &#8220;Admin_Bootstrap&#8221; classname corresponds to the module name &#8220;Admin&#8221;. So the Admin_Bootstrap class would launch behind the scene:</p>
<pre class="brush: php;">
new Zend_Application_Module_Autoloader(array(
   'namespace' =&gt; 'Admin',
   'basePath'  =&gt; APPLICATION_PATH . '/modules/admin',
));
</pre>
<p>But this is completely transparent&#8230;</p>
<h2>The special case of the &#8220;default&#8221; module</h2>
<p>In the case of the &#8220;Default&#8221; module, <a title="getModuleName()" href="http://framework.zend.com/apidoc/core/Zend_Application/Module/Zend_Application_Module_Bootstrap.html#getModuleName" target="_blank">getModuleName()</a> will return &#8220;Default&#8221; as the corresponding module name (because classname is Default_Bootstrap). So Zend_Application_Module_Bootstrap will configure the module Autoloader like this:</p>
<pre class="brush: php;">
new Zend_Application_Module_Autoloader(array(
 'namespace' =&gt; 'Default',
 'basePath'  =&gt; APPLICATION_PATH . '/modules/default',
));
</pre>
<p>It registers the namespace &#8220;Default&#8221; for the &#8220;default&#8221; folder&#8230; This is not the namespace we want to use, but &#8220;Application&#8221; is&#8230;</p>
<p>Meaning that trying to load:</p>
<pre class="brush: php;">
// application/modules/default/models/User.php
$user = new Application_Model_User();
</pre>
<p>&#8230; Will fail. If we want this to work, we should prefix all the classes of the &#8220;Default&#8221; module, with &#8220;Default_&#8221; instead of &#8220;Application_&#8221;, but this is not what we want to do. We want the &#8220;Default&#8221; module to use the namespace &#8220;Application&#8221;.</p>
<p>A quick workaround (and so far the best and cleanest solution I have found), is to override the getModuleName() method:</p>
<p><em>[ in Default_Bootstrap extends Zend_Application_Module_Bootstrap ]</em></p>
<pre class="brush: php;">
public function getModuleName()
{
 return &quot;Application&quot;;
}
</pre>
<p>So it will configure the &#8220;Default&#8221; module Autoloader like this:</p>
<pre class="brush: php;">
new Zend_Application_Module_Autoloader(array(
 'namespace' =&gt; 'Application',
 'basePath'  =&gt; APPLICATION_PATH . '/modules/default',
));
</pre>
<p>And you will be able to load your &#8220;Default&#8221; classes / Resources as usual:</p>
<pre class="brush: php;">
// application/modules/default/models/User.php
$user = new Application_Model_User();
</pre>
<h2>To sum up</h2>
<h3>Modular folder structure + Bootstrap files</h3>
<pre>application/
   modules/
      default/
         Bootstrap.php   // Default_Bootstrap extends Zend_Application_Module_Bootstrap

      admin/
         Bootstrap.php   // Admin_Bootstrap extends Zend_Application_Module_Bootstrap

      blog/
         Bootstrap.php   // Blog_Bootstrap extends Zend_Application_Module_Bootstrap

   Bootstrap.php   // Bootstrap extends Zend_Application_Bootstrap_Bootstrap</pre>
<h3>Application.ini</h3>
<pre>; bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

; front controller
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
...

; modules
resources.modules[] =</pre>
<p>This is all what you need in order to configure your modular application! All the default namespaces of the Zend Framework are automatically loaded for each module.</p>
<p>I hope this is gonna help somebody somewhere.</p>
<p>cheers.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bsagols.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bsagols.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bsagols.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=19&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bsagols.wordpress.com/2010/08/12/zend_loader_autoloader-stand-alone-and-modular-approaches/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2205033f2ad9b5931ee7eac7e46d1d54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bsagols</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework Style Javascript Redirect</title>
		<link>http://bsagols.wordpress.com/2010/05/20/zend-framework-style-javascript-redirect/</link>
		<comments>http://bsagols.wordpress.com/2010/05/20/zend-framework-style-javascript-redirect/#comments</comments>
		<pubDate>Thu, 20 May 2010 09:29:19 +0000</pubDate>
		<dc:creator>bsagols</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://bsagols.wordpress.com/?p=6</guid>
		<description><![CDATA[blog has moved I&#8217;ve moved my blog under my personal domain: http://bsagols.com/blog I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 &#8230; <a href="http://bsagols.wordpress.com/2010/05/20/zend-framework-style-javascript-redirect/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=6&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>blog has moved</h1>
<p>I&#8217;ve <a title="Blog moved to bsagols.com/blog" href="http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/">moved my blog</a> under my personal domain:</p>
<p><a title="bsagols blog" href="http://bsagols.com/blog/">http://bsagols.com/blog</a></p>
<p>I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 line in an .htaccess file ?!).</p>
<p>Here is the new URL of this post:</p>
<p><a title="bsagols blog - Zend Framework Style Javascript Redirect" href="http://bsagols.wordpress.com/2010/05/20/zend-framework-style-javascript-redirect/">bsagols / blog - Zend Framework Style Javascript Redirect</a></p>
<p>Here follows the original post&#8230;</p>
<p>- -</p>
<p>I wrote a simple javascript function that&#8217;s building a default Zend Framework URL and redirect the document to it.</p>
<p>My concern was to be able to send parameters through a javascript redirection to the Zend Framework. Basically instead of appending the parameters in the default way (&amp;param1=value1&amp;param2=&#8230;), it builds a compliant Zend Framework URL:</p>
<pre>www.example.com/controller/action/param1/value1/param2/value2</pre>
<p>Here is the snippet:</p>
<pre class="brush: jscript;">
function redirect(url, key, value)
{
	if(typeof(key) === 'undefined' &amp;&amp; typeof(value) === 'undefined')
	{
		document.location = url;
	}
	else
	{
		/*
		 * Example:
		 * 		- url = www.example.com/key1/value1/key2/value2/
		 * 		- key = &quot;key1&quot;
		 * 		- value = &quot;toto&quot;
		 */
		if(key !== null)
		{
			// index = 15
			var index = url.indexOf('/'+key+'/');

			var url1;
			// case 1: key is already present in URL
			if(index !== -1){

				// iafter = 21 = 15 + 4 (&quot;key1&quot;.length) + 2 (&quot;//&quot;.length)
				var iafter = index+key.length+2;

				// url1 = www.example.com/key1/
				url1 = url.substr(0, iafter);

				// index2 = 27 = 21 (iafter) + 6 (&quot;value1&quot;.length)
				var index2 = url.indexOf('/', iafter);
				if(index2 !== -1){
					// url2 = /key2/value2
					var url2 = url.substring(index2, url.length);
				}
			}
			// case 2: key is not present in URL
			else{
				// url1 = www.example.com/key3/ (let's say key = &quot;key3&quot;...)
				url1 = url + '/'+key+'/';
			}

			// case 1: url = www.example.com/key1/
			// case 2: url = www.example.com/key3/
			url = url1;
		}
		else
		{
			// if there is no &quot;/&quot; at the end of url, add it
			if(url.lastIndexOf('/') != (url.length-1))
				{url += '/';}
		}

		// case 1: url = www.example.com/key1/toto
		// case 2: url = www.example.com/key3/toto
		// case key == null: url = www.example.com/toto
		url += value;
		if(url2){
			// only case 1: url = www.example.com/key1/toto/key2/value2
			url += url2;
		}

		// redirect
		document.location = url;
	}
}
</pre>
<p>Examples using it:</p>
<pre class="brush: jscript;">
redirect(&quot;www.example.com&quot;);

redirect(&quot;www.example.com/controller1/action1&quot;, &quot;param1&quot;, &quot;value1&quot;);
// -&gt; www.example.com/controller1/action1/param1/value1

redirect(&quot;www.example.com/controller1/action1/param1/value1/param2/value2/&quot;, &quot;param1&quot;, &quot;newvalue1&quot;);
// -&gt; www.example.com/controller1/action1/param1/newvalue1/param2/value2&lt;/pre&gt;
</pre>
<p>A precision, it just covers my needs, you may want to improve it for example passing more than 1 parameter to append / replace&#8230;</p>
<p>Hope this kind of help somehow.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bsagols.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bsagols.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bsagols.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=6&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bsagols.wordpress.com/2010/05/20/zend-framework-style-javascript-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2205033f2ad9b5931ee7eac7e46d1d54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bsagols</media:title>
		</media:content>
	</item>
		<item>
		<title>Thought 0 (The beginning)</title>
		<link>http://bsagols.wordpress.com/2010/05/20/thought-0-the-beginning/</link>
		<comments>http://bsagols.wordpress.com/2010/05/20/thought-0-the-beginning/#comments</comments>
		<pubDate>Thu, 20 May 2010 08:35:29 +0000</pubDate>
		<dc:creator>bsagols</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[uml]]></category>

		<guid isPermaLink="false">http://bsagols.wordpress.com/?p=4</guid>
		<description><![CDATA[blog has moved I&#8217;ve moved my blog under my personal domain: http://bsagols.com/blog I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 &#8230; <a href="http://bsagols.wordpress.com/2010/05/20/thought-0-the-beginning/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=4&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>blog has moved</h1>
<p>I&#8217;ve <a title="Blog moved to bsagols.com/blog" href="http://bsagols.wordpress.com/2011/06/10/blog-moved-to-bsagols-comblog/">moved my blog</a> under my personal domain:</p>
<p><a title="bsagols blog" href="http://bsagols.com/blog/">http://bsagols.com/blog</a></p>
<p>I didn’t do the proper redirection ’cause it costs 12 $ a year and I don’t see the point paying for this (12 $ (a year !) to put 1 line in an .htaccess file ?!).</p>
<p>Here is the new URL of this post:</p>
<p><a title="bsagols blog - Thought 0 (The beginning)" href="http://bsagols.wordpress.com/2010/05/20/thought-0-the-beginning/">bsagols / blog - Thought 0 (The beginning)</a></p>
<p>Here follows the original post&#8230;</p>
<p>- -</p>
<p>Because web sites are getting more and more sophisticated/complicated, what about learning the Unified Modeling Language (UML) ?</p>
<p><a title="from wikipedia" href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" target="_blank">http://en.wikipedia.org/wiki/Unified_Modeling_Language</a></p>
<p>Official site: <a title="uml official site" href="http://www.uml.org/" target="_blank">http://www.uml.org/</a></p>
<p>And why not get an official certification ??</p>
<p><a title="uml certification overview" href="http://www.omg.org/uml-certification/overview.htm" target="_blank">http://www.omg.org/uml-certification/overview.htm</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bsagols.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bsagols.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bsagols.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bsagols.wordpress.com&amp;blog=13775596&amp;post=4&amp;subd=bsagols&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bsagols.wordpress.com/2010/05/20/thought-0-the-beginning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2205033f2ad9b5931ee7eac7e46d1d54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bsagols</media:title>
		</media:content>
	</item>
	</channel>
</rss>
