<?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>simon r jones &#187; Quick tips</title>
	<atom:link href="http://www.simonrjones.net/category/quick-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonrjones.net</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 00:06:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Checking your Zend Framework route order</title>
		<link>http://www.simonrjones.net/2011/02/checking-your-zend-framework-route-order/</link>
		<comments>http://www.simonrjones.net/2011/02/checking-your-zend-framework-route-order/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 08:39:39 +0000</pubDate>
		<dc:creator>Simon R Jones</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.simonrjones.net/?p=271</guid>
		<description><![CDATA[The order that you create your routes in Zend Framework is important, with the last route defined in your code being matched first. This allows you to set up custom routes and if these aren&#8217;t matched Zend Framework helpfully falls back to the default route which is set up first. If you have a lot [...]]]></description>
			<content:encoded><![CDATA[<p>The order that you create your routes in Zend Framework is important, with the last route defined in your code being matched first. This allows you to set up custom routes and if these aren&#8217;t matched Zend Framework helpfully falls back to the default route which is set up first. If you have a lot of routes though, set up in different places, it can get difficult to verify the order of your routes.</p>
<p>Just use this snippet of code in your controller to return a list of route names set up in your ZF application in the order they are matched via the routing system (i.e. the route at number 1 is matched first, then route 2, etc).</p>
<pre class="brush: php">// Output list of routes, in the order they are matched
echo '&lt;ol&gt;';
$routes = array_reverse($this-&gt;getFrontController()-&gt;getRouter()-&gt;getRoutes());
foreach ($routes as $name =&gt; $route) {
    echo "	&lt;li&gt;$name&lt;/li&gt;\n";
}
echo '&lt;/ol&gt;';</pre>
<p>Find out more about the <a href="http://framework.zend.com/manual/en/zend.controller.router.html">ZF Router</a> at the ZF manual.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrjones.net/2011/02/checking-your-zend-framework-route-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding the stack index for Zend Framework Controller plugins</title>
		<link>http://www.simonrjones.net/2010/07/undertstanding-zf-plugins-stack-index/</link>
		<comments>http://www.simonrjones.net/2010/07/undertstanding-zf-plugins-stack-index/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 10:34:29 +0000</pubDate>
		<dc:creator>Simon R Jones</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.simonrjones.net/?p=227</guid>
		<description><![CDATA[Zend Framework Controller plugins are a powerful way to inject logic into your controller system at various points, such as before and after an action dispatch. Plugins are run in the order they are added, though it is possible to change the order by defining a custom stack index. ZF internal plugins such as Zend_Controller_Plugin_ErrorHandler, [...]]]></description>
			<content:encoded><![CDATA[<p>Zend Framework Controller plugins are a powerful way to inject logic into your controller system at various points, such as before and after an action dispatch. Plugins are run in the order they are added, though it is possible to change the order by defining a custom stack index. ZF internal plugins such as Zend_Controller_Plugin_ErrorHandler, which displays a nice Error 404 page, has a stack index of 100 to ensure it runs near the end of any plugin cycle. However, it&#8217;s not so obvious from the <a href="http://zendframework.com/manual/en/zend.controller.plugins.html">ZF manual</a> how to set a custom stack index.<br />
<span id="more-227"></span><br />
For example, you may have a common admin system layout that does various things to your admin page layout before the page is displayed. This could be registered in your controller as so:</p>
<pre class="brush: php">
$front = $this->getFrontController();
$adminLayout = new My_Controller_Plugin_AdminLayout($this->_helper->layout());
$front->registerPlugin($adminLayout);
</pre>
<p>If you want to alter the plugin so it runs after any other local plugins you could specify a stack index of 10 as a second argument:</p>
<pre class="brush: php">$front->registerPlugin($adminLayout, 10);</pre>
<p>However, unless you know what the existing plugin stack indexes are it&#8217;s difficult to know what stack index you should be using. You can use this small code snippet to output the plugin name and its associated stack index, again via your controller.</p>
<pre class="brush: php">foreach ($front->getPlugins() as $stackIndex => $plugin) {
    Zend_Debug::dump(get_class($plugin), $stackIndex);
}</pre>
<p>The standard ZF plugin list should be something like:</p>
<pre>99 string(36) "Zend_Layout_Controller_Plugin_Layout"
100 string(35) "Zend_Controller_Plugin_ErrorHandler"
999 string(33) "Zend_Wildfire_Channel_HttpHeaders"</pre>
<p>Hope this helps shed light on a rather useful feature of ZF! You can find out more at this excellent Devzone article on <a href="http://devzone.zend.com/article/3372">Front Controller Plugins in Zend Framework</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrjones.net/2010/07/undertstanding-zf-plugins-stack-index/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Finding the Apache user in PHP</title>
		<link>http://www.simonrjones.net/2009/10/finding-apache-user/</link>
		<comments>http://www.simonrjones.net/2009/10/finding-apache-user/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 22:44:02 +0000</pubDate>
		<dc:creator>Simon R Jones</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Quick tips]]></category>

		<guid isPermaLink="false">http://www.simonrjones.net/?p=41</guid>
		<description><![CDATA[In PHP, knowing what the Apache user is on your webserver is very useful. Anything that writes a file to the server for example sessions, uploading files or other temporary file operations, needs to have the destination folder writeable by Apache. If you&#8217;re developing locally that&#8217;s not usually a problem. But as soon as you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>In PHP, knowing what the Apache user is on your webserver is very useful. Anything that writes a file to the server for example sessions, uploading files or other temporary file operations, needs to have the destination folder writeable by Apache. If you&#8217;re developing locally that&#8217;s not usually a problem. But as soon as you&#8217;re out in the real world file permission issues can sometimes be a pain.</p>
<p>If you&#8217;re having difficulties finding out what the Apache user is try this simple script to help you out.</p>
<p>It basically writes a small temporary file, checks the owner username, gets rid of the file and prints the Apache username to the screen. It should work on PHP4 and PHP5.</p>
<pre class="brush: php">$tmpFilename = tempnam('/tmp', 'TEST');
$handle = fopen($tmpFilename, 'w');
fwrite($handle, 'testdata');
fclose($handle);
$info = posix_getpwuid(fileowner($tmpFilename));
$apacheUser = $info['name'];
unlink($tmpFilename);
echo "The Apache user is $apacheUser";</pre>
<p>There&#8217;s also a small PHP source file you can easily download and use: <a href="/code/getApacheUser.phps">getApacheUser.phps</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonrjones.net/2009/10/finding-apache-user/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

