<?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>front controller &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/front-controller/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Zend Framework &#8211; quick tutorial (part 2)</title>
		<link>/2008/08/11/zend-framework-quick-tutorial-part-2-directory-layout-and-bootstrapping/</link>
		<comments>/2008/08/11/zend-framework-quick-tutorial-part-2-directory-layout-and-bootstrapping/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 10:25:38 +0000</pubDate>
		<dc:creator><![CDATA[stoimen]]></dc:creator>
				<category><![CDATA[featured]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[__autoload]]></category>
		<category><![CDATA[bootstrap.php]]></category>
		<category><![CDATA[directory layout]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[front controller]]></category>
		<category><![CDATA[quick start]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">/?p=55</guid>
		<description><![CDATA[Directory Layout and Bootstrapping. When someone starts with the learning of a framework, first he begins to read various articles to understand the basic rules to work with. There are a lot of tutorials how exactly to start, and there is also an official quick start guide, but beside this there are too much advices &#8230; <a href="/2008/08/11/zend-framework-quick-tutorial-part-2-directory-layout-and-bootstrapping/" class="more-link">Continue reading <span class="screen-reader-text">Zend Framework &#8211; quick tutorial (part 2)</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/06/19/zend-framework-quick-tutorial-part-3-front-controller-plugins/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins">Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins </a></li>
<li><a href="/2008/08/05/zend-framework-quick-tutorial-part-1-introduction/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 1)">Zend Framework &#8211; quick tutorial (part 1) </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Directory Layout and Bootstrapping.<br />
<a title="part 1 - introduction" href="/2008/08/05/zend-framework-quick-tutorial-part-1-introduction/"></a></h2>
<p>When someone starts with the learning of a framework, first he begins to read various articles to understand the basic rules to work with.</p>
<p>There are a lot of tutorials how exactly to start, and there is also an official quick start guide, but beside this there are too much advices how should you directory layout look like.</p>
<p>For me the following directory layout is working well. I don&#8217;t remember exactly where I&#8217;ve found it, but I think many people use it.</p>
<ul>
<li>application
<ul>
<li>admin</li>
<li>controllers</li>
<li>models</li>
<li>views</li>
</ul>
</li>
<li>content
<ul>
<li>controllers</li>
<li>models</li>
<li>views</li>
</ul>
</li>
<li>layouts</li>
<li>bootstrap.php</li>
<li>config.ini</li>
<li>library</li>
<li>Zend</li>
<li>public</li>
<li>index.php</li>
</ul>
<p>Almost half of the sources &#8220;how to start&#8221; recommend all of the initialization should be in index.php in the public folder. In fact all the logic of the public/private folders is that we don&#8217;t like to show anything on the web, and that&#8217;s why index.php contains only the following peace of code (it&#8217;s recommended to leave the file open from the ?&gt; closing tag):<br />
<code>&lt;?php<br />
require '../application/bootstrap.php';</code></p>
<p>Anything else, all the initialization is in bootstrap.php:</p>
<p>error_reporting (E_ALL | E_STRICT);</p>
<p>ini_set (&#8216;display_startup_errors&#8217;, 1);<br />
ini_set (&#8216;display_errors&#8217;, 1);</p>
<p>set_include_path (&#8216;../library&#8217; . PATH_SEPARATOR . get_include_path());</p>
<p>require_once &#8220;Zend/Loader.php&#8221;;<br />
Zend_Loader::registerAutoload();</p>
<p>$front = Zend_Controller_Front::getInstance();</p>
<p>$front-&gt;throwExceptions(true);</p>
<p>$front-&gt;setControllerDirectory(array(&#8216;default&#8217; =&gt; &#8216;../application/content/controllers&#8217;,<br />
&#8216;admin&#8217;   =&gt; &#8216;../application/admin/controllers&#8217;));</p>
<p>$front-&gt;dispatch();<br />
We set the error reporting to be ON, which si good when you develop any application and to collect all error messages. Than add the <em>library </em>folder in the include path with that line of code:</p>
<blockquote><p>set_include_path(&#8216;../library&#8217; . PATH_SEPARATOR . get_include_path());</p></blockquote>
<p>Next step is to start the __autoload functionality built in Zend Framework:</p>
<blockquote><p>require_once &#8220;Zend/Loader.php&#8221;;<br />
Zend_Loader::registerAutoload();</p></blockquote>
<p>Finally start the front controller which implements the singleton pattern and point to the two main directories &#8211; admin and content. I used them for administration panel and front end, but you can used as many as you application needs:<br />
<code>$front-&gt;setControllerDirectory(array('default' =&gt; '../application/content/controllers',<br />
'admin'   =&gt; '../application/admin/controllers'));</code></p>
<h3><span style="color: #800000;"><span style="text-decoration: underline;">Related Links</span></span></h3>
<p><a title="Zend_Db tutorial" href="/2009/03/19/zend-framework-zend-db-tutorial/" target="_self"><strong>Zend_Db tutorial</strong></a></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/06/19/zend-framework-quick-tutorial-part-3-front-controller-plugins/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins">Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins </a></li>
<li><a href="/2008/08/05/zend-framework-quick-tutorial-part-1-introduction/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 1)">Zend Framework &#8211; quick tutorial (part 1) </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2008/08/11/zend-framework-quick-tutorial-part-2-directory-layout-and-bootstrapping/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
