<?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>K. Aning&#039;s Web Log &#187; MVC Frameworks</title>
	<atom:link href="http://blog.kaning.co.uk/archives/category/mvc-frameworks/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kaning.co.uk</link>
	<description>Web development for the inexperienced and mildly skilled</description>
	<lastBuildDate>Mon, 31 Oct 2011 10:20:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mod_Rewrite and Zend Framework 1.10.x and Ubuntu</title>
		<link>http://blog.kaning.co.uk/archives/242</link>
		<comments>http://blog.kaning.co.uk/archives/242#comments</comments>
		<pubDate>Mon, 06 Sep 2010 21:22:35 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=242</guid>
		<description><![CDATA[So all the tutorials on configuring your development server to run Zend Framework successfully say that you need to enable mod_rewrite in apache2 so that .htaccess and Zend_Router* works well. What they all say is to make sure it&#8217;s loaded &#8230; <a href="http://blog.kaning.co.uk/archives/242">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So all the tutorials on configuring your development server to run Zend Framework successfully say that you need to enable mod_rewrite in apache2 so that .htaccess and Zend_Router* works well.</p>
<p>What they all say is to make sure it&#8217;s loaded and enabled. I will raise my hand and say it wasn&#8217;t that easy for me to find because Ubuntu lays out Apache2 a little differently from say Fedora. First of all in the /etc/apache2 folder there are a few folders to take note of.</p>
<p>sites-enabled and mods-enabled actually tell you what has been enabled or not and not an uncommented list in some httpd.conf file. Basically the folders in there have symbolic links that come from sites-available and mods-available. This perhaps is a better idea as you can add new mods and not have to recompile apache or whatever.</p>
<p>I digress, to enable mod_rewrite in apache2 in Ubuntu 10.04.1 you need to create a symbolic link from mods-available to mods-enabled to do this you can either use the command:</p>
<pre class="brush:shell">sudo ln -s /etc/mods-available/rewrite.load /etc/mods-enabled/rewrite.load</pre>
<p>or if you prefer GUIs you have to run nautilus as root so you can try</p>
<pre class="brush:shell">sudo nautilus</pre>
<p>and navigate to &#8220;/etc/mods-available&#8221;, right-click on rewrite.load and select &#8220;make link&#8221; and the cut the new file created called &#8220;link to rewrite.load&#8221; paste it in mods-enabled and rename it to &#8220;rewrite.load &#8221;</p>
<p>Now all you need to do is restart your web server and you&#8217;re all set to reroute anyhow you want.</p>
<pre class="brush:shell">sudo /etc/init.d/apache2 restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/242/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Image Manipulation with Zend</title>
		<link>http://blog.kaning.co.uk/archives/233</link>
		<comments>http://blog.kaning.co.uk/archives/233#comments</comments>
		<pubDate>Sun, 15 Aug 2010 12:20:33 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=233</guid>
		<description><![CDATA[I had been on the prowl for an MVC approach to image manipulation. Especially a method that did it the Zend way. In the forums and documentation for the framework the developers didn&#8217;t see a real need to implement a &#8230; <a href="http://blog.kaning.co.uk/archives/233">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had been on the prowl for an MVC approach to image manipulation. Especially a method that did it the Zend way. In the forums and documentation for the framework the <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Image+Proposal+-+Davey+Shafik">developers didn&#8217;t see a real need to implement</a> a &#8220;Zend_Image&#8221; class in the libraries as this was already available through the PHP GD and Imagick hooks.</p>
<p>Some of us however did and there are a <a href="http://www.ajaxray.com/blog/2008/09/12/image-manipulation-in-zend-framework-with-php-thumbnailer-class-v20/" target="_blank">few tutorials</a> on how to incorporate the <a href="http://www.gen-x-design.com/projects/php-thumbnailer-class/" target="_blank">PHPThumb library</a> into Zend. I have used the PHPThumb Library on the <a href="http://mokocharlie.com" target="_blank">mokocharlie.com</a> project and found it I however stumbled on a much simpler way of doing this that feels more native to the framework Zend_Image is that implementation hidden <a href="http://code.google.com/p/zend-image/" target="_blank">somewhere on the code.google.com</a> hosting servers.</p>
<pre class="brush:php">$image = new Zend_Image( APPLICATION_PATH.'/../public/media/images/large/'.$filename,
   new Zend_Image_Driver_Gd());
   $transform = new Zend_Image_Transform($image);
   if($image-&gt;getWidth() &gt; $image-&gt;getHeight()){
       $transform-&gt;fitToWidth(295)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/medium/'.$filename);
       $transform-&gt;fitToWidth(147)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/small/'.$filename);
       $transform-&gt;center()-&gt;middle()-&gt;crop(74, 74)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/tiny/'.$filename);
   }else{
       $transform-&gt;fitToHeight(300)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/medium/'.$filename);
       $transform-&gt;fitToWidth(147)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/small/'.$filename);
       $transform-&gt;center()-&gt;middle()-&gt;crop(74, 74)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/tiny/'.$filename);
   }</pre>
<p>The above is my implementation of it as I create three versions of an uploaded image.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/233/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A question on Zend_Acls</title>
		<link>http://blog.kaning.co.uk/archives/228</link>
		<comments>http://blog.kaning.co.uk/archives/228#comments</comments>
		<pubDate>Wed, 28 Jul 2010 08:47:01 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend_Acl]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=228</guid>
		<description><![CDATA[So I have been playing with the Zend_Acl for a while now and I managed to integrate it with this site I am working on. I am however asking myself a few questions here. What is the best way to &#8230; <a href="http://blog.kaning.co.uk/archives/228">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I have been playing with the Zend_Acl for a while now and I managed to integrate it with this site I am working on.</p>
<p>I am however asking myself a few questions here. What is the best way to implement an ACL, which by the way is an Access Control List. On one hand I can do my &#8220;isAllowed&#8221; checks at the controller level, but do I want the user to get that far?</p>
<p>The other option is to implement our acl in the bootstrap file which always runs first and so makes it easier to check access even before the user gets to the routing and all that.</p>
<p>Now my problem is that I am a big fan of the MVC concept and by the very dynamic nature of the way I am working on this project, my ACLs are provided by a separate datastore i.e a database.</p>
<p>I don&#8217;t want to start calling in database adaptors and all that at bootstrap level, because that is just not nice. So I suppose the option here is to go with restricting access at in the init function of my controller.</p>
<p>Par example:</p>
<pre class="brush:php">$this-&gt;authObject = Zend_Auth::getInstance();
        // if not logged in, redirect to login form
        if (!$this-&gt;authObject-&gt;hasIdentity()) {
            $returnURL = urlencode('/admin');
            $this-&gt;_redirect('/login?returnUrl=' . $returnURL);
        } else {
            $this-&gt;userData = $this-&gt;authObject-&gt;getStorage();
            $this-&gt;userRole = $this-&gt;userData-&gt;read()-&gt;role;
        }
//some other instantiations here
if($this-&gt;accessControl-&gt;isAllowed($this-&gt;userRole)){
            $adminNavigation = Zend_Registry::get('AdminNavigation');
            $this-&gt;view-&gt;sideNavigation = $adminNavigation;

            $uri = $this-&gt;_request-&gt;getPathInfo();
            $this-&gt;view-&gt;uri = $uri;
        }else{
            $miscNavigation = Zend_Registry::get('MiscNavigation');
            $this-&gt;view-&gt;sideNavigation = $miscNavigation;
            $this-&gt;view-&gt;errorMessage = "This account does not have
enough permissions to be here";
        }</pre>
<p>You may notice from all this that I have an Admin Controller and based on our isAllowed value, we provide either an admin navigation or a misc one.</p>
<p>Obviously this can be rewritten to fit the purpose but it&#8217;s an example of using ACLs at the controller level.</p>
<p>Feedback welcome</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/228/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Having multiple instances of Zend Navigation in a single View</title>
		<link>http://blog.kaning.co.uk/archives/216</link>
		<comments>http://blog.kaning.co.uk/archives/216#comments</comments>
		<pubDate>Fri, 09 Jul 2010 10:30:44 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Zend_Navigation]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=216</guid>
		<description><![CDATA[so I have been playing around with the Zend Framework rather extensively over the past few weeks and it has been a very rewarding experience. I am posting this here because it was a bit difficult finding a work around &#8230; <a href="http://blog.kaning.co.uk/archives/216">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>so I have been playing around with the Zend Framework rather extensively over the past few weeks and it has been a very rewarding experience.</p>
<p>I am posting this here because it was a bit difficult finding a work around for the issue I describe below.</p>
<p>Zend Navigation had been giving me a lot of problems especially because I could not get the Navigation object passed to my view object to render two different navigation configs. The top menu which remains the same for all pages and is rendered in my layout and other sub menus rendered in my individual view pages.</p>
<p>Now getting to it:</p>
<p>in my bootstrap I initialise my navigation with something like this.</p>
<pre>
<pre class="brush:php">$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
 $miscNavConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/miscnavigation.xml', 'nav');
 $navigation = new Zend_Navigation($config);
 $miscNavigation = new Zend_Navigation($miscNavConfig);
 Zend_Registry::set(Zend_Navigation, $navigation);
 Zend_Registry::set('MiscNavigation', $miscNavigation);
 $view-&gt;navigation($navigation);</pre>
</pre>
<p>Now  lines 2, 4, and 6 are the new lines I have added for additional nagivation. I beleive you should be able to add new configurations as you move along if you need to.</p>
<p>The next bit was retrieving the sub navigation in my controller:</p>
<pre>
<pre class="brush:php">$miscNavigation = Zend_Registry::get('MiscNavigation');
$this-&gt;view-&gt;miscnavigation = $miscNavigation;</pre>
</pre>
<p>You can do this in your view but because I route several of my views through this controller I want to have to do it only once.</p>
<p>And finally in my view:</p>
<pre>
<pre class="brush:php">$options = array('ulClass' =&gt; 'submenu');
echo($this-&gt;navigation()-&gt;menu()-&gt;renderMenu($this-&gt;miscnavigation, $options));</pre>
</pre>
<p>Bear in mind that I use the renderMenu method instead of passing $this-&gt;miscnavigation into the menu method. If you do that you will overwrite any other instances of menu you have on the page with the miscnavigation object.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/216/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

