<?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>Emran Hasan&#039;s Blog</title>
	<atom:link href="http://phpfour.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpfour.com/blog</link>
	<description>The everyday sharing of Emran Hasan on software development.</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:39:05 +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>A clean way of integrating PHPUnit 3.5.x with CodeIgniter 2.x</title>
		<link>http://phpfour.com/blog/2012/01/phpunit-integration-with-codeigniter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=phpunit-integration-with-codeigniter</link>
		<comments>http://phpfour.com/blog/2012/01/phpunit-integration-with-codeigniter/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 11:10:51 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[phpunit]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=441</guid>
		<description><![CDATA[Now a days, my default choice of framework is always Zend Framework. However, I have to maintain a couple live projects in CodeIgniter from early days. I feel its very important to have tests around critical applications, so I have attempted a couple times to integrate PHPUnit with CodeIgniter but failed every time &#8211; well, [...]]]></description>
			<content:encoded><![CDATA[<p>Now a days, my default choice of framework is always Zend Framework. However, I have to maintain a couple live projects in CodeIgniter from early days. I feel its very important to have tests around critical applications, so I have attempted a couple times to integrate PHPUnit with CodeIgniter but failed every time &#8211; well, until now. </p>
<p>I&#8217;ve managed it this time with hooks. It provides a clean way of bootstrapping the framework and then performing tests on the Model layer &#8211; for me testing the model layer has been sufficient. The use is very simple as it does not require any change in how a regular CodeIgniter application is built. </p>
<p>Grab the code from <a href="https://github.com/phpfour/CodeIgniter" target="_blank">github</a>.</p>
<p><strong>Example &#8211; /tests/PostTest.php</strong></p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> PostTest <span style="color: #000000; font-weight: bold;">extends</span> PHPUnit_Framework_TestCase<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$CI</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">database</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'testing'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testGetsAllPosts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-441"></span></p>
<p><strong>How it works</strong></p>
<ul>
<li>The provided PHPUnit bootstrap file sets the CI environment as <em>testing</em> and then loads the framework normally &#8211; the code is taken directly from the index.php file.</li>
<li>A <em>display_override</em> hook checks if the environment is set to <em>testing</em> or not and when it is, it refrains from outputting the rendered view file</li>
<li>The PHPUnit test case file now can get a reference of the CI object using the commonly used <em>&amp;get_instance()</em> method and can load models and other libraries as needed.</li>
<li>It is good to have separate database configuration for testing and it might be useful to load the test database with fresh data every time test runs &#8211; it can be easily added in the setUp method using the Database Forge classes</li>
</ul>
<p>Let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2012/01/phpunit-integration-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>To me design is&#8230;</title>
		<link>http://phpfour.com/blog/2012/01/to-me-design-is/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=to-me-design-is</link>
		<comments>http://phpfour.com/blog/2012/01/to-me-design-is/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 16:16:59 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=432</guid>
		<description><![CDATA[A great compilation by Vostok Studios on what great designers think about design.]]></description>
			<content:encoded><![CDATA[<p>A great compilation by <a href="http://www.vostokstudio.com/" target="_blank">Vostok Studios</a> on what great designers think about <em>design</em>.</p>
<p><iframe src="http://player.vimeo.com/video/17995436?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="610" height="350"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2012/01/to-me-design-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painless Ruby and Rails installation on Ubuntu/Mint</title>
		<link>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=painless-ruby-and-rails-installation-on-ubuntumint</link>
		<comments>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 05:28:16 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=384</guid>
		<description><![CDATA[It took me an hour to properly install the latest versions of ruby, rails and its mysql binder. Although its less than a 5 mins task, I had to search in forums, blogs to deal with the various errors. So just posting this so its easy for someone else to get done with this in [...]]]></description>
			<content:encoded><![CDATA[<p>It took me an hour to properly install the latest versions of ruby, rails and its mysql binder. Although its less than a 5 mins task, I had to search in forums, blogs to deal with the various errors. So just posting this so its easy for someone else to get done with this in 5 mins.</p>
<p>1. Open Terminal and install <a href="https://rvm.beginrescueend.com/" target="_blank">RVM (Ruby Version Manager)</a></p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
<p>2. Enter the following in ~/.bash_profile and/or ~/.bashrc (replace YOUR USER NAME with the username you&#8217;re logged in with):</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;/home/YOUR USER NAME/.rvm/scripts/rvm&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #ff0000;">&quot;/home/YOUR USER NAME/.rvm/scripts/rvm&quot;</span> &nbsp;<span style="color: #666666; font-style: italic;"># This loads RVM into a shell session.</span></div></div>
<p>3. Install Ruby 1.9.2</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2</div></div>
<p><span id="more-384"></span><br />
4. Set it as the ruby version to use through rvm:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rvm use 1.9.2</div></div>
<p>5. Install latest version of Rails:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</div></div>
<p>6. Install mysql bindings:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> libmysql-ruby libmysqlclient-dev<br />
gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql</div></div>
<p>7. Now you should be able to create a rails project with mysql binding:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rails new hello<br />
bundle <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up central Mercurial server in Ubuntu</title>
		<link>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-central-mercurial-server-in-ubuntu</link>
		<comments>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/#comments</comments>
		<pubDate>Sat, 07 May 2011 20:33:32 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[dev process]]></category>
		<category><![CDATA[dev team]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=342</guid>
		<description><![CDATA[It&#8217;s been a while since we&#8217;ve been thinking about moving to Mercurial from Subversion at our company. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mercurial.selenic.com/"><img class="alignleft" title="Mercurial" src="http://mercurial.selenic.com/images/mercurial-logo.png" alt="Mercurial" width="184" height="61" /></a></p>
<p>It&#8217;s been a while since we&#8217;ve been thinking about moving to Mercurial from Subversion at our <a href="http://www.rightbrainsolution.com">company</a>. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.</p>
<p>Although it&#8217;s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for your dev team.</p>
<p><span id="more-342"></span><br />
1. Log onto your server using SSH</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ssh</span> admin<span style="color: #000000; font-weight: bold;">@</span>rbs-server.com</div></div>
<p>2. Install mercurial from repository:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mercurial</div></div>
<p>3. We need to have a directory to store our Mercurial configuration and repository files, so let&#8217;s create one and change it&#8217;s owner to the apache user so that apache can access them:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> hg<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> hg<span style="color: #000000; font-weight: bold;">/</span>repos<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data:www-data hg<span style="color: #000000; font-weight: bold;">/</span>repos</div></div>
<p>4. We&#8217;ll be creating a configuration that will allow us to host multiple repositories in this server. And we&#8217;ll be using CGI to serve the files through Apache:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>mercurial<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>hgweb.cgi .<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x hgweb.cgi</div></div>
<p>5. We need to show the location of the config file to the CGI script, so open the file <strong>hgweb.cgi</strong> with nano or vim to update the line with &#8220;config = &#8230;&#8221; with the following and save it.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config = &quot;/var/hg/hgweb.config&quot;</div></div>
<p>6. Now let&#8217;s create the file <strong>/var/hg/hgweb.config</strong> and write the location of the repositories:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> hgweb.config</div></div>
<p>Enter the following content and save the file:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[collections]<br />
/var/hg/repos = /var/hg/repos</div></div>
<p>7. As a final step, we&#8217;ll need to update the Apache configuration so that it executes the CGI when requested with a <strong>/hg</strong> prefix:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> default</div></div>
<p>At the end of the defaul virtual host configuration and just before the &lt;/VirtualHost&gt; tag, add the following and save it:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ScriptAlias /hg &quot;/var/hg/hgweb.cgi&quot;<br />
<br />
AuthType Basic<br />
AuthName &quot;Mercurial repositories&quot;<br />
AuthUserFile /var/hg/hgusers<br />
Require valid-user</div></div>
<p>8. In order to take effect of the above change, we&#8217;ll need to restart apache:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apache2ctl restart</span></div></div>
<p>9. Now you should be able to visit the server&#8217;s /hg location like <strong>http://rbs-server.com/hg</strong> from browser. However, you&#8217;ll be greeted with a username/password prompt as we&#8217;ve enabled that in our apache configuration above. So, lets add some user for our use.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<br />
htpasswd <span style="color: #660033;">-mc</span> hgusers admin</div></div>
<p>It will ask for the password of the user admin twice and after you enter that, it will be stored in the file <strong>hgusers</strong>. You can add more users in the similar fashion, just ignore the <strong>c</strong> parameter as it was used to create the file first time:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">htpasswd <span style="color: #660033;">-m</span> hgusers abid<br />
htpasswd <span style="color: #660033;">-m</span> hgusers saeed<br />
...</div></div>
<p>10. Now visit the /hg path in your browser and you&#8217;ll see the empty list of repositories after you authenticate.</p>
<p>11. By default Mercurial only allows pushing changes through SSL, but in our case it was not necessary. Also, we wanted to give all our developers the push access to the repositories. For that, let&#8217;s update the system-wide mercurial configuration file <strong>/etc/mercurial/hgrc</strong> by adding the following lines at the end of the file and saving it:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[web]<br />
allow_push = *<br />
push_ssl = false</div></div>
<p>12. Now that all is set, let&#8217;s setup a test repository so that we can clone it in our development machine:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<span style="color: #000000; font-weight: bold;">/</span>repos<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #7a0874; font-weight: bold;">test</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #7a0874; font-weight: bold;">test</span><br />
hg init</div></div>
<p>This repository can now be accessed through <strong>http://rbs-server.com/hg/test</strong> and can be cloned in a development machine with the following command (mercurial must be installed already):</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<br />
hg clone http:<span style="color: #000000; font-weight: bold;">//</span>rbs-server.com<span style="color: #000000; font-weight: bold;">/</span>hg<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span></div></div>
<p>Hope this will make someone&#8217;s life easy. Enjoy the beauty of Mercurial!</p>
<p><a href="http://www.flickr.com/photos/burnblue/109530851/" target="_blank">Photo source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>2011</title>
		<link>http://phpfour.com/blog/2011/01/happy-new-year-2011/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=happy-new-year-2011</link>
		<comments>http://phpfour.com/blog/2011/01/happy-new-year-2011/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 12:29:25 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[new year]]></category>

		<guid isPermaLink="false">http://localhost/phpfour/wordpress/?p=317</guid>
		<description><![CDATA[First, a very happy new year to everybody!!! The last year has showed me the ups and downs of life and I believe 2011 will be a great year. Some of my wishes in 2011 would be: Re-shaping my company to become a major OSS based company in Bangladesh Doing something meaningful for my country [...]]]></description>
			<content:encoded><![CDATA[<p>First, a very happy new year to everybody!!! The last year has showed me the ups and downs of life and I believe 2011 will be a great year. Some of my wishes in 2011 would be:</p>
<ul>
<li>Re-shaping my company to become a major OSS based company in Bangladesh</li>
<li>Doing something meaningful for my country</li>
<li>Learning Ruby and related frameworks (Rails, Cucumber, etc)</li>
<li>Spending more time my family</li>
<li>Having more fun with my friends</li>
<li>Living a healthy life</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2011/01/happy-new-year-2011/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Developing better PHP projects</title>
		<link>http://phpfour.com/blog/2010/11/developing-better-php-projects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=developing-better-php-projects</link>
		<comments>http://phpfour.com/blog/2010/11/developing-better-php-projects/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 14:45:25 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[best-practice]]></category>
		<category><![CDATA[coding techniques]]></category>
		<category><![CDATA[phpxperts]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=302</guid>
		<description><![CDATA[I presented this talk yesterday on the phpXperts seminar 2010 &#8211; the largest PHP group in Bangladesh. My objective was to give a quick overview on project structure, development practices and use of tools to improve the overall quality of the PHP projects. So here goes the presentation:]]></description>
			<content:encoded><![CDATA[<p>I presented this talk yesterday on the phpXperts seminar 2010 &#8211; the largest PHP group in Bangladesh. My objective was to give a quick overview on project structure, development practices and use of tools to improve the overall quality of the PHP projects.</p>
<p>So here goes the presentation:</p>
<div style="width:425px; text-align: center; margin: 0 auto;" id="__ss_5688159"><object id="__sse5688159" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=developingbetterphpprojects-101106140513-phpapp01&#038;stripped_title=developing-better-php-projects&#038;userName=phpfour" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5688159" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=developingbetterphpprojects-101106140513-phpapp01&#038;stripped_title=developing-better-php-projects&#038;userName=phpfour" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/11/developing-better-php-projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick start on new Facebook PHP SDK (IFrame based)</title>
		<link>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-start-on-new-facebook-php-sdk-iframe-based</link>
		<comments>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/#comments</comments>
		<pubDate>Mon, 03 May 2010 20:39:46 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Graph API]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=278</guid>
		<description><![CDATA[This post is more than 1 year old. It solved the issues when the SDK was first released and facebook had lack of documentation. However, now facebook has very rich set of documnetation and you should follow that instead! The new Facebook API has already spread over the application developers and if you&#8217;re like me, [...]]]></description>
			<content:encoded><![CDATA[<div style="color: #fff; background-color: #AE0700; padding: 10px; text-align:justify;">This post is more than 1 year old. It solved the issues when the SDK was first released and facebook had lack of documentation. However, now facebook has very rich set of <a href="http://developers.facebook.com/docs/">documnetation</a> and you should follow that instead!</div>
<p>The new <a href="http://developers.facebook.com/docs/" target="_blank">Facebook API</a> has already spread over the application developers and if you&#8217;re like me, you&#8217;ve already got your hands dirty to see how this new thing works. If you have tried to follow the documentation to <a href="http://developers.facebook.com/docs/guides/canvas/#auth" target="_blank">authorize/get session</a> in your canvas application, it is likely you have already hit roadblocks. Well, I am no savior but I have glued together a few clues and got it working for myself.</p>
<p>I am assuming that you have already created your application by following the <a href="http://developers.facebook.com/docs/guides/canvas/#canvas" target="_blank">Getting Started</a> section from the official documentation. Also, this is for <strong>IFrame based</strong> applications only.</p>
<p>Enough talking, let&#8217;s get some code.</p>
<p><strong><span style="text-decoration: underline;">Step 1: Get the new SDK</span></strong></p>
<p>Download the new SDK from <a href="http://github.com/facebook/php-sdk/" target="_blank">github</a>. We will only need the <strong>facebook.php</strong> file from the <strong>src</strong> folder. In our project directory, let&#8217;s create a folder called &#8220;lib&#8221; and put the file there.</p>
<p><strong><span style="text-decoration: underline;">Step 2: A configuration file</span></strong></p>
<p>Let&#8217;s now create a configuration file to store our facebook configuration. Let&#8217;s name it <strong>config.php</strong>. Here goes the source:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_APP_ID&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'113795715321151'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_API_KEY&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'064baf5fb98de050cd7b9a001ca1988b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_SECRET_KEY&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'430f43c01f6dfe02c284b4545976f9ce'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_CANVAS_URL&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://apps.facebook.com/emran-test-app/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><strong><span style="text-decoration: underline;">Step 3: Application Main Page</span></strong></p>
<p>This file will be the main entry point to our facebook application. It just instantiates the facebook object, sets the configuration and checks for a valid session. If it does not find a valid session, it redirects to the login page. For first time visitors, it will be the authorization page. On later requests, the operation will occur in the background &#8211; without any user interaction.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'lib/facebook.php'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'config.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'appId'</span> &nbsp;<span style="color: #339933;">=&gt;</span> FACEBOOK_APP_ID<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> FACEBOOK_SECRET_KEY<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'phpfour.com'</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'canvas'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;script type='text/javascript'&gt;top.location.href = '<span style="color: #006699; font-weight: bold;">$url</span>';&lt;/script&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; try <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$me</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, F j, Y&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You last updated your profile on &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$updated</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-278"></span></p>
<p>You might be wondering &#8211; it&#8217;s pretty straight-forward, so what&#8217;s the catch ? Well, to be honest, the documentation does not have the &#8220;canvas&#8221; parameter mentioned anywhere which does the primary magic here. Also, if you do not use the javascript trick, then you end up with an authorization dialog with full facebook UI within the iframe itself (see below).</p>
<p><a href="http://www.phpfour.com/img/fb-auth-without-js.png"><img class="aligncenter size-medium wp-image-281" title="Auth without JS redirect" src="http://www.phpfour.com/img/fb-auth-without-js.png" alt="" width="300" height="213" /></a></p>
<p><strong><span style="text-decoration: underline;">CodeIgniter Version</span></strong></p>
<p>Here is the CodeIgniter version of the above example. The significance is that CodeIgniter removes the values from the $_GET super global &#8211; which is required for the library to work. We thus re-populate it on the constructor ourselves and start a session to share data among subsequent page visits.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #b1b100;">include_once</span> APPPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'libraries/facebook-php-sdk/facebook.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #000000; font-weight: bold;">extends</span> Controller<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/parse_str"><span style="color: #990000;">parse_str</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'appId'</span> &nbsp;<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'facebook_app_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'facebook_secret_key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'phpfour.com'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'canvas'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;script type='text/javascript'&gt;top.location.href = '<span style="color: #006699; font-weight: bold;">$url</span>';&lt;/script&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$me</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, F j, Y&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You last updated your profile on &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$updated</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Hope I am able to help a few people.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/feed/</wfw:commentRss>
		<slash:comments>206</slash:comments>
		</item>
		<item>
		<title>Enterprise PHP</title>
		<link>http://phpfour.com/blog/2010/02/enterprise-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enterprise-php</link>
		<comments>http://phpfour.com/blog/2010/02/enterprise-php/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 12:11:13 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[enterprise]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[softexpo]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=273</guid>
		<description><![CDATA[I presented this talk on the Soft Expo 2010 &#8211; the largest software fair in Bangladesh. The intention was to clear some of the misconception about PHP, the growth of PHP, how it can fit in the enterprise now, etc. After these, I shed light on some topics that a company/developer should keep in mind [...]]]></description>
			<content:encoded><![CDATA[<p>I presented this talk on the Soft Expo 2010 &#8211; the largest software fair in Bangladesh. The intention was to clear some of the misconception about PHP, the growth of PHP, how it can fit in the enterprise now, etc.</p>
<p>After these, I shed light on some topics that a company/developer should keep in mind in order to write good software in PHP. This was followed by live session on caching, mysql query optimization, use of Xdebug, etc.</p>
<p>So here goes the presentation:</p>
<div style="margin: 0pt auto; width:425px; text-align: center;" id="__ss_3176537"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=enterprisephp-100214110838-phpapp01&#038;stripped_title=enterprise-php-3176537" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=enterprisephp-100214110838-phpapp01&#038;stripped_title=enterprise-php-3176537" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>And a big thanks to Ivo Jansch&#8217;s &#8220;<a href="http://www.slideshare.net/ijansch/php-in-the-real-world">PHP in the real wolrd</a>&#8221; presentation, from where I took inspiration.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/02/enterprise-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Changing the default controller naming convention in CodeIgniter</title>
		<link>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codeigniter-controller-naming-convention-modified</link>
		<comments>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 06:23:04 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=265</guid>
		<description><![CDATA[CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal [...]]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal error is inevitable and I have to forcefully change the name of the conflicting class to something less desirable (say from Users to UsersModel). Today I wanted to end this problem.</p>
<p>So I extended the <strong>CI_Router</strong> core class and made change to the <em>_validate_request</em> method. Now I can name my controller classes in this fashion: <strong>UsersController</strong> and it resides on the file system as <strong>controllers/UsersController.php</strong>. If you&#8217;ve tried other established frameworks, you should notice that this naming convention is widely used. So, if you have the same need, then just download the MY_Router.php file and put it on your application/libraries folder. That&#8217;s it.</p>
<p>Here is how your controller would start:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> UsersController <span style="color: #000000; font-weight: bold;">extends</span> Controller<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-265"></span><br />
If you&#8217;d like to have a look at the code, here is the source for quick view:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/defined"><span style="color: #990000;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp;* MY_Router<br />
&nbsp;*<br />
&nbsp;* Extended the core CI_Router class in order to force a different naming<br />
&nbsp;* convention for controllers.<br />
&nbsp;*<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> MY_Router <span style="color: #000000; font-weight: bold;">extends</span> CI_Router<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Suffix in controller name<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @var String<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_suffix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Controller&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Call the parent constructor<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* This is a requirement for extending base CI core class. Just abiding by<br />
&nbsp; &nbsp; &nbsp;* the rules.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp;public<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp;void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MY_Router<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span><span style="color: #004000;">CI_Router</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Validates the supplied segments. &nbsp;Attempts to determine the path to<br />
&nbsp; &nbsp; &nbsp;* the controller.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp; private<br />
&nbsp; &nbsp; &nbsp;* @param &nbsp; &nbsp;array<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp; array<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> _validate_request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retain the original segments</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$orgSegments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the root folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// OK, revert to the original segment</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$orgSegments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Is the controller in a sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the directory and remove it from the segment array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_directory</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_method</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the default controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">directory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Can't find the requested controller...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Facebook Developer Garage Dhaka – Open Stream API</title>
		<link>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish</link>
		<comments>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 03:26:05 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[facebook garage]]></category>
		<category><![CDATA[open stream]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=255</guid>
		<description><![CDATA[The first ever &#8220;Facebook Developer Garage&#8221; took place in Dhaka, Bangladesh and I am proud to be a part of it. I was one of the speakers of this spectacular event organized by Facebook and IBT bangladesh. I spoke about the recently released Open Stream API from Facebook. It was more of an overview rather [...]]]></description>
			<content:encoded><![CDATA[<p>The first ever &#8220;Facebook Developer Garage&#8221; took place in Dhaka, Bangladesh and I am proud to be a part of it. I was one of the speakers of this spectacular event organized by Facebook and IBT bangladesh. I spoke about the recently released Open Stream API from Facebook. It was more of an overview rather than a detail one. Here goes the slides:</p>
<div style="margin: 0pt auto; width:425px; text-align: center;" id="__ss_1898723"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=facebookgarage-090824045242-phpapp01&#038;stripped_title=facebook-open-stream-api-facebook-developer-garage-dhaka" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=facebookgarage-090824045242-phpapp01&#038;stripped_title=facebook-open-stream-api-facebook-developer-garage-dhaka" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>I have created a quick start example which outlines both Facebook Connect and the Open Stream API. You can check that <a href="http://www.phpfour.com/fbstream/">here</a>. A blog post covering the steps is coming soon in 3-4 days.</p>
<p>Stay tuned if you have interest in them.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: phpfour.com @ 2012-02-04 11:40:29 -->
