<?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>cobbweb</title>
	<atom:link href="http://www.cobbweb.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cobbweb.me</link>
	<description>PHP, Zend Framework, Doctrine and more</description>
	<lastBuildDate>Sat, 22 May 2010 11:51:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>API Documentation for PHP 5.3</title>
		<link>http://www.cobbweb.me/2010/05/api-documentation-for-php-5-3/</link>
		<comments>http://www.cobbweb.me/2010/05/api-documentation-for-php-5-3/#comments</comments>
		<pubDate>Sat, 22 May 2010 11:48:49 +0000</pubDate>
		<dc:creator>cobby</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[namespaces]]></category>

		<guid isPermaLink="false">http://www.cobbweb.me/?p=16</guid>
		<description><![CDATA[If you are like me, then you&#8217;ve probably just gone to run your latest library code through phpDocumentor, only to get a bunch of problems all to do with namespaces. But fear not! After a round of tedious searching I finally found a solution, PHPDoctor. Well, it&#8217;s actually a fork version I found on GitHub. [...]]]></description>
			<content:encoded><![CDATA[<p>If you are like me, then you&#8217;ve probably just gone to run your latest library code through phpDocumentor, only to get a bunch of problems all to do with namespaces. But fear not! After a round of tedious searching I finally found a solution, PHPDoctor. Well, it&#8217;s actually a fork version I found on GitHub. It operates pretty much identically to phpDocumentor but all your configurations are stored in an INI file and it has no web interface. </p>
<p>The only bad thing about PHPDoctor is it&#8217;s output. I found the default output to be a little boring, so I&#8217;ve gone through and copied a few elements from one of the phpDocumentor&#8217;s frames templates. PHPDoctor doesn&#8217;t have modular templates like phpDocumentor, and having to modify PHPDoctors code was a chore &#8211; it&#8217;s source code is disgusting&#8230; The other thing it is missing is the JavaScript TreeMenu.</p>
<p>Enough blabbering, here is my custom version of PHPDoctor with namespace support. Included is a basic Phing task as well, because I am such a nice fellow.<br />
<a href="http://www.cobbweb.me/downloads/php/Cobbys_PHPDoctor.tar.gz">Cobby&#8217;s PHPDoctor</a></p>
<p>If anyone is interested, I would be keen on making a new API doc generator in PHP 5.3 with some actual coding standards.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cobbweb.me/2010/05/api-documentation-for-php-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework Action Helpers and Namespaces</title>
		<link>http://www.cobbweb.me/2010/05/zend-action-helpers-and-namespaces/</link>
		<comments>http://www.cobbweb.me/2010/05/zend-action-helpers-and-namespaces/#comments</comments>
		<pubDate>Sat, 22 May 2010 00:09:50 +0000</pubDate>
		<dc:creator>cobby</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.cobbweb.me/?p=3</guid>
		<description><![CDATA[In my current Zend Framework project, I am using PHP 5.3&#8217;s namespaces for all my library code (It makes sense considering I&#8217;m using Doctrine 2 and will attempt to upgrade to ZF 2 when it&#8217;s released). I have come across a few compatibility issues when trying to use namespaces, mostly with Zend&#8217;s PluginLoader and Phing. [...]]]></description>
			<content:encoded><![CDATA[<p>In my current <a href="http://www.zendframework.com">Zend Framework</a> project, I am using PHP 5.3&#8217;s namespaces for all my library code (It makes sense considering I&#8217;m using <a href="http://www.doctrine-project.org">Doctrine 2</a> and will attempt to upgrade to ZF 2 when it&#8217;s released). I have come across a few compatibility issues when trying to use namespaces, mostly with Zend&#8217;s PluginLoader and <a href="http://www.phing.info">Phing</a>. Below is how I have my action helpers setup:</p>
<pre>
site/
  library/
    Cob/
      Controller/
        Action/
          HelperBroker.php
          Helper/
            Myhelper.php
            HelperAbstract.php
</pre>
<p><strong>HelperBroker.php</strong></p>
<pre class="brush: php;">
&lt;?php

namespace Cob\Controller\Action;

use \Zend_Controller_Action_HelperBroker;

/**
 * Custom implementation of the HelperBroker to provide namespace support
 *
 * @author Andrew Cobby
 */

class HelperBroker extends Zend_Controller_Action_HelperBroker {

    /**
     * Add a namespace prefix (works the same as Zend_Helper_BrokerBroker::addPrefix()
     *
     * @param string $prefix Namespace prefix
     */
    static public function addNamespacePrefix($prefix)
    {
        $prefix = rtrim($prefix, '\\') . '\\';
        $path = str_replace('\\', DIRECTORY_SEPARATOR, $prefix);
        $path = rtrim($path, '/');
        self::getPluginLoader()-&gt;addPrefixPath($prefix, $path);
    }

    /**
     * Adds an array of helpers
     *
     * @param array $helpers Helpers
     */
    static public function addHelpers(array $helpers)
    {
        foreach($helpers as $helper){
            parent::addHelper($helper);
        }
    }

}
</pre>
<p><strong>HelperAbstract.php</strong></p>
<pre class="brush: php;">
&lt;?php

namespace Cob\Controller\Action\Helper;

use \Zend_Controller_Action_Helper_Abstract;

/**
 * Abstract helper for namespaced action helpers
 *
 * @author Andrew Cobby
 */

class HelperAbstract extends Zend_Controller_Action_Helper_Abstract
{

    /**
     * Fix to get the correct helper name (Overrides Zend_Controller_Action_HelperAbstract::getName)
     *
     * @return string
     */
    public function getName()
    {
        $className = get_class($this);
        if(strpos($className, '\\') !== false){
            $helperName = strrchr($className, '\\');
            return ltrim($helperName, '\\');
        }elseif(strpos($className, '_') !== false){
            $helperName = strrchr($className, '_');
            return ltrim($className, '_');
        }else{
            return $className;
        }
    }

}
</pre>
<p><strong>Myhelper.php</strong></p>
<pre class="brush: php;">
&lt;?php

namespace Cob\Controller\Action\Helper;

/**
 * Example helper that uses namespaces
 *
 * @author Andrew Cobby
 */

class Myhelper extends HelperAbstract
{

    public function direct()
    {
        return 'Namespaces are cool!!';
    }

}
</pre>
<p>Before you starting using this, you will need to add your namespace prefix in our new HelperBroker:</p>
<pre class="brush: php;">
&lt;?php

namespace Cob\Controller;

use \Zend_Controller_Action;
use \Cob\Controller\Action\HelperBroker as HelperBroker;

class Action extends Zend_Controller_Action
{

    public function preDispatch()
    {
        HelperBroker::addNamespacePrefix('Cob\Controller\Action\Helper\\'); // remember 2 trailing slashes to fix the escaping
        $coolio = $this-&gt;_helper-&gt;Myhelper(); // calling a helper is still the same
    }
}
</pre>
<p>As you can see, the only real part of the compatibility issue is overriding HelperAbstract::getName(), the methods in HelperBroker are more just for convenience.<br />
Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cobbweb.me/2010/05/zend-action-helpers-and-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
