<?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>My Beloved PHP</title>
	<atom:link href="http://www.mybelovedphp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mybelovedphp.com</link>
	<description>The Art of Quick &#38; Dirty Programming</description>
	<lastBuildDate>Mon, 14 May 2012 13:19:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Tips for using the Netbeans editor for Kohana and Kostache / Mustache templates using `surround with`</title>
		<link>http://www.mybelovedphp.com/2012/05/14/tips-for-using-the-netbeans-editor-for-kohana-and-kostache-mustache-templates-using-surround-with/</link>
		<comments>http://www.mybelovedphp.com/2012/05/14/tips-for-using-the-netbeans-editor-for-kohana-and-kostache-mustache-templates-using-surround-with/#comments</comments>
		<pubDate>Mon, 14 May 2012 13:01:36 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=138</guid>
		<description><![CDATA[A nice feature of NetBeans is the support for `code templates`: abbreviations that expand into snippets of code when the TAB key is pressed after typing the a shortcut in the editor. You can type fn TAB and have it expand to That&#8217;s very convenient for long and often needed code phrases. `Surround with` code [...]]]></description>
			<content:encoded><![CDATA[<p>A nice feature of <strong>NetBeans</strong> is the support for `code templates`: abbreviations that expand into snippets of code when the TAB key is pressed after typing the a shortcut in the editor.</p>
<p>You can type fn TAB and have it expand to</p>
<pre class="brush: php; title: ; notranslate">
function blabla () {

}
</pre>
<p>That&#8217;s very convenient for long and often needed code phrases.</p>
<h3>`Surround with` code templates</h3>
<p>Another very useful feature is the `surround with` code snippet. It isn&#8217;t very well documented on the <strong>Netbeans</strong> PHP pages, well more or less not at all, but you can add your own snippets for `surround with` too.</p>
<p>If your using <a href="http://mustache.github.com/" target="_blank">Mustache templates</a> with the <a href="http://kohanaframework.org/" target="_blank">Kohana</a> framework, you will find the next snippet extremely useful, when you&#8217;re updating your templates multilingual. Mustache templates are very clean and elegant template files that work with a myriad of languages like <strong>PHP</strong>, <strong>Python</strong> and <strong>Javascript</strong>. Also they escape code automatically, so I really can recommend them. No more logic in the HTML template files, well just the most basic.</p>
<p>For example you have this <strong>Mustache</strong> template:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h2&gt;Recipes&lt;/h2&gt;
&lt;ul&gt;
{{#recipes}}
	&lt;li&gt;{{name}}&lt;/li&gt;
{{/recipes}}
&lt;/ul&gt;
</pre>
<p>To make it multilingual for use with <strong>Kostache</strong> we have to change it to:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h2&gt;{{#__}}Recipes{{/__}}&lt;/h2&gt;
</pre>
<p>To do that in <strong>Netbeans</strong> add this to the code templates: tools -&gt; options -&gt; editor -&gt; tab `Code templates` -&gt; new</p>
<p>It doesn&#8217;t matter what you choose for abbreviation, because were not gonna use it as code completion with shortcut TAB, but surround with is triggered with SHIFT ENTER.</p>
<p>Choose something like translation, then paste this:</p>
<pre class="brush: xml; title: ; notranslate">
{{#__}}${selection allowSurround}{{/__}}
</pre>
<p><a href="http://www.mybelovedphp.com/wp-content/uploads/2012/05/Options_060.png"><img class="alignnone size-medium wp-image-143" title="Options_060" src="http://www.mybelovedphp.com/wp-content/uploads/2012/05/Options_060-300x232.png" alt="" width="380" /></a><br />
Now go back to your template, select Recipes, and press SHIFT ENTER or click the yellow light-bulb. That will offer the extra command `surround with` your snippet.</p>
<p>Not documented on the <strong>Netbeans</strong> PHP wiki, but extremely useful.</p>
<p>The needed PHP function in your view class:</p>
<pre class="brush: php; title: ; notranslate">
public function __() {
return array('i18n', 'get');
 }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2012/05/14/tips-for-using-the-netbeans-editor-for-kohana-and-kostache-mustache-templates-using-surround-with/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS vendor prefix macro for Netbeans</title>
		<link>http://www.mybelovedphp.com/2012/02/15/css-vendor-prefix-macro-for-netbeans/</link>
		<comments>http://www.mybelovedphp.com/2012/02/15/css-vendor-prefix-macro-for-netbeans/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 15:50:46 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=130</guid>
		<description><![CDATA[There is all about CSS vendor prefixes at the moment. PPK doesn&#8217;t like them at all, the W3C is afraid that webkit might rule the world, developers seem to find that webkit is the only mobile browser around. Agreed, the CSS vendor prefixes make verbose code. It&#8217;s ugly, and sometimes it&#8217;s a lot of typing. [...]]]></description>
			<content:encoded><![CDATA[<p>There is all about CSS vendor prefixes at the moment. <a href="http://www.quirksmode.org/blog/archives/2010/03/css_vendor_pref_1.html" target="_blank">PPK doesn&#8217;t like them at all</a>, the<a href="http://www.glazman.org/weblog/dotclear/index.php?post/2012/02/09/CALL-FOR-ACTION%3A-THE-OPEN-WEB-NEEDS-YOU-NOW" target="_blank"> W3C is afraid that webkit might rule the world</a>, developers seem to find that webkit is the only mobile browser around.</p>
<p>Agreed, the CSS vendor prefixes make verbose code. It&#8217;s ugly, and sometimes it&#8217;s a lot of typing. But they pinpoint a real problem, browsers need them, and although maybe obsolete in the future, if you want your code cross browser now and future-proof you simply have to use them. No matter if they&#8217;re going to be abolished or not. No matter what solutions is to be found tomorrow.</p>
<p>But what most people fail to notice, that it&#8217;s actually an IDE/deployment problem. If IDE can spellcheck and code-complete why can&#8217;t they extend CSS prefixed rules.</p>
<p>Well they can. So we created a macro for Netbeans. Netbeans is our favourite PHP-IDE.  The macro recorder in Netbeans is easy and fast, so it suits.</p>
<p>Just add  a Macro in Netbeans: tools -&gt; options -&gt;  editor -&gt; macros -&gt; new.</p>
<p>Paste this</p>
<pre class="brush: plain; title: ; notranslate">

copy-selection-else-line-down copy-selection-else-line-down copy-selection-else-line-down copy-selection-else-line-down copy-selection-else-line-down caret-up caret-up caret-up caret-up caret-begin-line caret-forward delete-next &quot;moz&quot; caret-down caret-begin-line caret-forward selection-forward &quot;ms&quot; caret-down caret-backward selection-backward &quot;webkit&quot; caret-down caret-backward caret-backward caret-backward caret-backward caret-backward selection-backward &quot;khtml&quot; caret-down caret-backward caret-backward caret-backward delete-previous delete-previous delete-previous
</pre>
<p>And give it a proper shortcut CTRL + ] is free.</p>
<p>Then start writing your code for the least popular browser, but it has the <a href="http://dev.webonomic.nl/why-i-use-opera-as-my-main-browser" target="_blank">shortest prefix vendor</a>: Opera.</p>
<pre class="brush: css; title: ; notranslate">

-o-transition: opacity 1s ease-in 1s;
</pre>
<p>Put your cursor soemwhere in the line and press CTRL + ]</p>
<p>You get this result</p>
<pre class="brush: css; title: ; notranslate">

-o-transition: opacity 1s ease-in 1s;
 -moz-transition: opacity 1s ease-in 1s;
 -ms-transition: opacity 1s ease-in 1s;
 -webkit-transition: opacity 1s ease-in 1s;
 -khtml-transition: opacity 1s ease-in 1s;
 transition: opacity 1s ease-in 1s;
</pre>
<p>Probably khtml can be skipped, I don&#8217;t know the market share, but let&#8217;s try to support everything.</p>
<p>Has become hell a heaven. No but it isn&#8217;t that bad any more. Are they&#8217;re caveats. Sure, like different implementations, but that should be corrected by hand.</p>
<p>Important thing is, the rule without a prefix should end the list.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2012/02/15/css-vendor-prefix-macro-for-netbeans/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Suppressing errors in PHP with control operator @</title>
		<link>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/</link>
		<comments>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 15:08:17 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=125</guid>
		<description><![CDATA[Errors give valuable information, it&#8217;s worth paying attention to. Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can&#8217;t solve. Reading something into simpleXML that isn&#8217;t 100% validated XML, because it&#8217;s encoded in ISO-8859 instead of UTF-8. Then use the PHP one error control operator @. When [...]]]></description>
			<content:encoded><![CDATA[<p>Errors give valuable information, it&#8217;s worth paying attention to.</p>
<p>Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can&#8217;t solve.</p>
<p>Reading something into simpleXML that isn&#8217;t 100% validated XML, because it&#8217;s encoded in ISO-8859 instead of UTF-8.</p>
<p>Then use the PHP one error control operator @.</p>
<blockquote><p>When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.</p></blockquote>
<p>Tha comes quite in hand in the following piece of code :</p>
<pre class="brush: php; title: ; notranslate">

$xml = @simplexml_load_file('rssfeed.xml');
</pre>
<p>No more errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating csv content</title>
		<link>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/</link>
		<comments>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 14:50:03 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=121</guid>
		<description><![CDATA[It is tempting to simply generate CSV data with writing comma-separated  array-values. Unfortunately this obvious way of doing turns out to be a bad idea. Often it seems to be working at first, but eventually you&#8217;ll be faced with annoying bugs, wrongly escaped data. Fortunately, PHP has a native function to write CSV values to [...]]]></description>
			<content:encoded><![CDATA[<p>It is tempting to simply generate CSV data with writing comma-separated  array-values.</p>
<pre class="brush: php; title: ; notranslate">
implode(&quot;,&quot;, $data_array);
</pre>
<p>Unfortunately this obvious way of doing turns out to be a bad idea. Often it seems to be working at first, but eventually you&#8217;ll be faced with annoying bugs, wrongly escaped data.</p>
<p>Fortunately, PHP has a native function to write CSV values to a file. </p>
<pre class="brush: php; title: ; notranslate">
fputcsv()
</pre>
<p>With a little trick you can use this function to write values to the screen.<br />
Use the built-in streamwrappers:</p>
<pre class="brush: php; title: ; notranslate">
 $outstream = fopen(&quot;php://output&quot;, 'w');
 fputcsv($outstream, $data_array, ',', '&quot;');
 fclose($outstream);
</pre>
<p>This will echo the data to the screen.<br />
Most people won&#8217;t know `php://output`. A pity it&#8217;s really powerful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fix broken UTF8 encoded RSS feeds in php</title>
		<link>http://www.mybelovedphp.com/2009/07/03/fix-broken-utf8-encoded-rss-feeds-in-php/</link>
		<comments>http://www.mybelovedphp.com/2009/07/03/fix-broken-utf8-encoded-rss-feeds-in-php/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 19:21:23 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=99</guid>
		<description><![CDATA[Parsing feeds with the SimpleXML object is a walk in the park. But it can turn into a pain in the ass, when the provided XML feed isn&#8217;t correctly UTF8 encoded and I can tell you, there are some ugly ones out there in the wild. Parsing RSS feeds with SimpleXML Normally you can load [...]]]></description>
			<content:encoded><![CDATA[<p>Parsing feeds with the SimpleXML object is a walk in the park. But it can turn into a pain in the ass, when the provided XML feed isn&#8217;t correctly UTF8 encoded and I can tell you, there are some ugly ones out there in the wild.</p>
<h3>Parsing RSS feeds with SimpleXML</h3>
<p>Normally you can load and parse a feed as simple as:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?
$feed = simplexml_load_file(rss.xml);

foreach ($feed-&gt;channel-&gt;item as $item){ ?&gt;
  &lt;h3&gt;&lt;?= $item-&gt;title ?&gt;&lt;/h3&gt;
  &lt;p&gt;&lt;?= $item-&gt;description ?&gt;&lt;/p&gt;
&lt;? } ?&gt;
</pre>
<p>That&#8217;s a standard. Sometimes though the XML is not proper UTF8 encoded, and the following nasty error occurs loading in into the SimpleXML object.</p>
<p><strong>Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 6: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xEB 0x6C 0&#215;65 0&#215;20 in index.php on line 33</strong></p>
<h3>How to fix this</h3>
<p>First I tried to filter out the bad characters with str_replace, but that&#8217;s silly. I didn&#8217;t feel right. So I looked further and I stumbled on this quite unknow function iconv.</p>
<p>What&#8217;s the iconv module</p>
<blockquote><p>This module contains an interface to iconv character set conversion facility. With this module, you can turn a string represented by a local character set into the one represented by another character set, which may be the Unicode character set. Supported character sets depend on the iconv implementation of your system. </p></blockquote>
<p>The iconv function is available since PHP 4.0.5</p>
<pre class="brush: php; title: ; notranslate">
Description

string iconv ( string $in_charset , string $out_charset , string $str )

Performs a character set conversion on the string str from in_charset to out_charset .
</pre>
<h3>A better and safer way of parsing</h3>
<p>To be on the safe side, never read in a feed directly into a SimpleXML object, but do it this way:</p>
<pre class="brush: php; title: ; notranslate">
$feed = file_get_contents($feed_url);

$feed = iconv(&quot;UTF-8&quot;,&quot;UTF-8//IGNORE&quot;,$feed);

$feed = simplexml_load_string($feed);
</pre>
<p>There is another reason to do this. Reading in a feed with file_get_contents is much faster then loading it straight into a SimpleXML object , at least in PHP < 5.2x. </p>
<p>So following above instructions you will experience a performance gain and get rid of some nasty unexpected errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/07/03/fix-broken-utf8-encoded-rss-feeds-in-php/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Dating takes time, women are difficult but PHP?</title>
		<link>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/</link>
		<comments>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:28:11 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=81</guid>
		<description><![CDATA[One of the big annoyances is having a blog or webpage in a certain language and that all the dates appear on your website in English. Of course you can choose just numbered formats, but sometimes the month or the day of the week in words adds that needed little extra polish. Formatting a date [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big annoyances is having a blog or webpage in a certain language and that all the dates appear on your website in English. Of course you can choose just numbered formats, but sometimes the month  or the day of the week in words adds that needed little extra polish.</p>
<h5>Formatting a date in PHP</h5>
<p>Normally a date is formatted like this with the <strong>date() </strong>function:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?= date('d-m-Y') ?&gt;
</pre>
<h5>Formatting a localised date in PHP</h5>
<p>But to format a date in your preferred language you need to use the <strong>strftime</strong> function:</p>
<blockquote><p>Format the time and/or date according to locale settings. Month and weekday names and other language-dependent strings respect the current locale set with setlocale().</p></blockquote>
<p>So we also need the <strong>setlocale()</strong><strong> </strong>function. This function let you set the language to use for the formatting. Your system or server should have them installed, otherwise it&#8217;s not possible! And most of them are not installed by default, although easily available.<br />
What does the <strong>setlocale() </strong>function do:</p>
<blockquote><p>Returns the new current locale, or FALSE if the locale functionality is not implemented on your platform, the specified locale does not exist or the category name is invalid.<br />
An invalid category name also causes a warning message. Category/locale names can be found in <a href="http://www.faqs.org/rfcs/rfc1766">RFC 1766</a> and <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm">ISO 639</a>. Different systems have different naming schemes for locales.</p></blockquote>
<p>Tough pages to consume to be honest, but let&#8217;s go on.</p>
<h5>Locales settings on your server</h5>
<p>You can find the installed localisations in this file on a Linux server:</p>
<pre class="brush: xml; title: ; notranslate">
vi var/lib/locales/supported.d/local
</pre>
<p>My server only had one line by default!<br />
Simply add the one&#8217;s you&#8217;re missing. You can find all possible localisations in this file:</p>
<pre class="brush: xml; title: ; notranslate">
/usr/share/i18n/SUPPORTED
</pre>
<p>Don&#8217;t add them all: it will decrease performance.</p>
<p>So we&#8217;re nearly done:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?
setlocale(LC_TIME,'nl-NL.UTF-8');
echo strftime('%s-$b-%y',time())
?&gt;
</pre>
<p>You need to enter the correct encoding aswell, otherwise it won&#8217;t work. This is dependent of the server settings, so it will influence the portability of your code a bit.<br />
Above code will give you the current date in Dutch, but we need another function to create localised dates from stored timestamps of the MySQL database.</p>
<h5>Converting stored Timestamps to PHP understandable format</h5>
<p>A MySQL timestamp value won&#8217;t work as a direct input to the strftime function. We need to convert it with another function: <strong>strtotime</strong>.</p>
<p>So we end up with something like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?
setlocale(LC_TIME,'nl-NL.UTF-8');
echo strftime('%A %d $b %y',strtotime($row-&gt;timestamp))
?&gt;
</pre>
<p><strong>Quite a long road to take for a boring date!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.2.9 released</title>
		<link>http://www.mybelovedphp.com/2009/02/27/php-529-released/</link>
		<comments>http://www.mybelovedphp.com/2009/02/27/php-529-released/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 11:15:32 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=75</guid>
		<description><![CDATA[The PHP development team would like to announce the immediate availability of PHP 5.2.9. This release focuses on improving the stability of the PHP 5.2.x branch with over 50 bug fixes, several of which are security related. All users of PHP are encouraged to upgrade to this release. Security Enhancements and Fixes in PHP 5.2.9: [...]]]></description>
			<content:encoded><![CDATA[<p>The PHP development team would like to announce the immediate availability of PHP 5.2.9.</p>
<p>This release focuses on improving the stability of the PHP 5.2.x branch with over 50 bug fixes, several of which are security related. All users of PHP are encouraged to upgrade to this release.</p>
<p>Security Enhancements and Fixes in PHP 5.2.9:</p>
<ul>
<li>Fixed security issue in imagerotate(), background colour isn&#8217;t validated correctly with a non truecolour image. Reported by Hamid Ebadi, APA Laboratory (Fixes CVE-2008-5498). (Scott)</li>
<li>Fixed a crash on extract in zip when files or directories entry names contain a relative path. (Pierre)</li>
<li>Fixed explode() behavior with empty string to respect negative limit. (Shire)</li>
<li>Fixed a segfault when malformed string is passed to json_decode(). (Scott)</li>
</ul>
<p>Further details about the PHP 5.2.9 can be found in the release announcement for 5.2.9, the full list of changes is available in the ChangeLog for PHP 5.<br />
<a href="http://www.php.net/index.php#id2009-02-26-1">Read more here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/02/27/php-529-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans: Code Completion for the Kohana Framework</title>
		<link>http://www.mybelovedphp.com/2009/01/27/netbeans-code-completion-for-the-kohana-framework/</link>
		<comments>http://www.mybelovedphp.com/2009/01/27/netbeans-code-completion-for-the-kohana-framework/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 15:02:04 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=50</guid>
		<description><![CDATA[In some earlier posts I&#8217;ve described ways to get Netbeans code completion working for CodeIgniter. In this post I will show you how to do the same for Kohana. Kohana is originally a PHP-5 only fork of CodeIgniter, but it has developed into much more. Now all code has been rewritten, so only the framework [...]]]></description>
			<content:encoded><![CDATA[<p>In some earlier posts I&#8217;ve described ways to get Netbeans code completion working for CodeIgniter. In this post I will show you how to do the same for Kohana.</p>
<p><a href="http://kohanaphp.com/">Kohana</a> is originally a PHP-5 only fork of CodeIgniter, but it has developed into much more. Now all code has been rewritten, so only the framework in concept is based on CodeIgniter. It has nice ORM, AUTH and Cache modules.</p>
<p>It&#8217;s easy to convert and actually I prefer Kohana, it&#8217;s more intuitive and extensible. The only drawback: Kohana needs PHP 5.2+, where CI can be used with PHP 4.</p>
<p>Kohana uses the PHP class autoload feature, no need to include class files manually, PHP will lookup the file on the included path automatically at the moment the class is mentioned.<br />
So when you write.<br />
<code>$this->db = New Database</code><br />
The Database class declaration file will be loaded by PHP automatically. This way of lading classes is also understandable for the auto completion parser of Netbeans.</p>
<p>This is in contrast to CodeIgniter, because there classes are loaded like:<br />
<code>$this->load->library('validation')</code></p>
<p>To achieve code completion for CodeIgniter in Netbeans we have to manually insert comments to help the auto completion parser map properties to classes:<br />
<code>* @property CI_DB_active_record $db</code></p>
<p>That&#8217;s not the case in Kohana, but there is another problem. Kohana uses Class suffixes. The classes are declared like Database_Core, but called like Database (without the _Core).<br />
To evade that we grap to the <a href="http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/">netbeans_ci_code_autocompletion helper file</a> trick. But here we don&#8217;t write the property in comments, we simple do this:<br />
<code>Class Database extends Database_Core{}<br />
etc</code><br />
You can see the discussion on which this post is based in the <a href="http://forum.kohanaphp.com/comments.php?DiscussionID=230">Kohana forum</a>. There is even a script that will generate the file automatically, so it will do extensions aswell. Works for Zend, Netbeans and Eclipse. </p>
<p>You can find the script here:</p>
<p>http://www.mapledesign.co.uk/code/kohana-zend-autocomplete/</p>
<p>There is a nasty flaw though on the website, they mixed up names. The script should be activated by:</p>
<p>http://yoursite/zend_ide</p>
<p>And it will create a zend_autocomplete.php file in the cache directory. You can move that to the nbproject folder if you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/01/27/netbeans-code-completion-for-the-kohana-framework/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Netbeans revisited: Code Completion for Code-igniter II</title>
		<link>http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/</link>
		<comments>http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 12:42:14 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=42</guid>
		<description><![CDATA[In an earlier post I described a way to achieve PHP code completion in Netbeans for the CodeIgniter framework. That way consisted of inserting property comments &#8211; which functioned as a helper for Netbeans to interprete the use &#8211; in every user application controller. This post will describe an even easier way, but first some [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://www.mybelovedphp.com/2009/01/27/netbeans-revis…ode-igniter">earlier post</a> I described a way to achieve PHP code completion in <a href="http://www.netbeans.org/">Netbeans</a> for the CodeIgniter framework. That way consisted of inserting property comments &#8211; which functioned as a helper for Netbeans to interprete the use &#8211; in every user application controller. This post will describe an even easier way, but first some comments about the earlier post.</p>
<p>I showed some ways to automate the inserting of the comments, although writing phpDocumentor comments in Netbeans is supported natively. Just type /** and completion will be available like explained <a href="http://codeigniter.com/forums/viewthread/94145/#522295">here</a>. </p>
<p>It&#8217;s a good custom to write comments in phpDoc style, it will help users to understand your coding, and it will offer an extremely easy way to publish documentation about your programs. Read here more about <a href="http://www.phpdoc.org/">phpDOC</a>.</p>
<p>On more remark, I wrote to include the CodeIgniter path in the  Netbeans Global Include Path, it&#8217;s definitely better to do it on a project basis, so include it in the PHP Include Path in the Project Properties. Otherwise you will have CodeIgniter completion on projects that don&#8217;t use CI. <img src='http://www.mybelovedphp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now were getting to the core of this post. Probably the easiest way to achieve code completion is to put a file in the source path of Netbeans, but out of the CodeIgniter application or systems paths, let&#8217;s say a file called `netbeans_ci_code_completion.php`, but you can give it any name you want.</p>
<p>Make a text file with this content:<br />
<code><br />
< ?<br />
/**<br />
* @property CI_Loader $load<br />
* @property CI_Form_validation $form_validation<br />
* @property CI_Input $input<br />
* @property CI_Email $email<br />
* @property CI_DB_active_record $db<br />
* @property CI_DB_forge $dbforge<br />
* @property CI_Table $table<br />
* @property CI_Session $session<br />
* @property CI_FTP $ftp<br />
* ....<br />
 */<br />
Class Controller {<br />
}<br />
?><br />
</code></p>
<p>It doens&#8217;t matter how you call it, as long it has a php extension and is seen by Netbeans but not CodeIgniter. You can save it in a folder called temp, or even in the nbproject (netbeans project folder) folder. I worked for me, and I&#8217;ve haven&#8217;t noticed any drawbacks yet.</p>
<p>For most of my projects I have this project folder structure:</p>
<p><code><br />
/application<br />
/error<br />
/images<br />
/nbproject<br />
/scripts<br />
/styles<br />
index.php<br />
.htaccess<br />
</code></p>
<p>Putting it in the nbproject folder has the advantage that the file will not by copied to the server automatically, because that folder is already marked to be excluded in the synchronization settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Netbeans revisited: Code Completion for Code-igniter</title>
		<link>http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/</link>
		<comments>http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 14:53:01 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=31</guid>
		<description><![CDATA[Some software you like, you start working with it, and you feel like it&#8217;s made for you. Everyday you discover a little bit more of all the hidden powers. That&#8217;s the good thing about open source, there is so much power that has yet to be discovered. Most commercial software claim a lot of features [...]]]></description>
			<content:encoded><![CDATA[<p>Some software you like, you start working with it, and you feel like it&#8217;s made for you. Everyday you discover a little bit more of all the hidden powers. That&#8217;s the good thing about open source, there is so much power that has yet to be discovered. Most commercial software claim a lot of features in their marketing brochures and disappoint enormously in the end when you start working.</p>
<p>Netbeans 6.5 is good software, out of the box it offers code completion and validation for php, html, css, javascript including jquery, mootools etc.</p>
<p>Code Igniter is a rapid development framework for  PHP, it&#8217;s a flexible MVC-like system. Netbeans let you easily implements CodeIgniter powers, by offering code completion for CodeIgniter&#8217;s native Active record classes, libraries and helpers functions.</p>
<p><a href="http://www.mybelovedphp.com/wp-content/uploads/2009/01/codeigniter_netbeans_code.png"><img src="http://www.mybelovedphp.com/wp-content/uploads/2009/01/codeigniter_netbeans_code-300x226.png" alt="" title="codeigniter_netbeans_code" width="300" height="226" class="alignnone size-medium wp-image-37" /></a></p>
<p>You need to set it up though, and here we will explain how:</p>
<p>The first step is only neccesary if you have moved the system folder out of the Netbeans project source folder that contains the application folder, in case of a multi site set up or something.</p>
<p>Add the CodeIgniter System folder to the Netbeans Global Include Path:</p>
<p><code>Tools>Options>PHP>Add folder to  Global Include Path</code></p>
<p>This will give code completion for the helper functions and some more, but not for the Active record or database functions in a controller.</p>
<p><code>$this->db->...</code></p>
<p>To achieve more power, add this to your controller:<br />
<code><?<br />
/**<br />
* @property CI_Loader $load<br />
* @property CI_Form_validation $form_validation<br />
* @property CI_Input $input<br />
* @property CI_Email $email<br />
* @property CI_DB_active_record $db<br />
* @property CI_DB_forge $dbforge<br />
*/</p>
<p>class Stylist extends Controller<br />
</code><br />
Now you can type<br />
<code>$this->db->...</code><br />
or<br />
<code>$this->dbforge->...</code><br />
And you will get all available functions offered. Wow!</p>
<p>To make it really easy, add this to Tools->Options->Editor->Code Templates</p>
<ol>
<li>
<ol>
<li>New -> abbreviation: <code>db</code></li>
<li>Expanded text: `<code>$this->db-></code>`</li>
</ol>
</li>
<li>
<ol>
<li>New -> abbreviation: <code>`codei`</code></li>
<li>Expanded text: `
<p><code>/**<br />
* @property CI_Loader $load<br />
* @property CI_Form_validation $form_validation<br />
* @property CI_Input $input<br />
* @property CI_Email $email<br />
* @property CI_DB_active_record $db<br />
* @property CI_DB_forge $dbforge<br />
*/<br />
</code></p>
</li>
</ol>
</li>
</ol>
<p>Now you can easily insert the Codeigniter code just above your controller, by typing  `codei` and TAB<br />
or db TAB for $this->db-></p>
<p>That rocks, doesn`t it.</p>
<p>See also <a href='http://blogs.sun.com/netbeansphp/entry/screencat_about_class_property_variables'>here</a> and <a href="http://codeigniter.com/forums/viewthread/94145/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

