<?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>SourceHosting.blog &#187; Software Development</title>
	<atom:link href="http://blog.sourcehosting.net/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sourcehosting.net</link>
	<description>Various ramblings on the subjects of SaaS, software development, source code control, configuration management and entrepreneurship</description>
	<lastBuildDate>Mon, 20 Jul 2009 17:17:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<image>
<link>http://blog.sourcehosting.net</link>
<url>http://blog.sourcehosting.net/wp-content/mbp-favicon/favicon.ico</url>
<title>SourceHosting.blog</title>
</image>
		<item>
		<title>Avoid Monotonous Tasks With WWW::Mechanize</title>
		<link>http://blog.sourcehosting.net/2009/07/17/perl-www-mechanize-scripting/</link>
		<comments>http://blog.sourcehosting.net/2009/07/17/perl-www-mechanize-scripting/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 18:59:22 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/?p=199</guid>
		<description><![CDATA[Hi everyone, A SourceHosting.net client recently asked to create a large number of users in a custom installation of phpDeadlock that he uses to manage access to his Subversion repository here. Since phpDeadlock doesn&#8217;t have a user management API, this sounded like a monotonous, error-prone task.  After entering 10-15 users, the chances of misspelling a [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_202" class="wp-caption alignright" style="width: 345px"><a href="http://en.wikipedia.org/wiki/Per_Georg_Scheutz"><img class="size-full wp-image-202" title="The Scheutz Mechanical Calculator" src="http://www.sourcehosting.net/blog-media/2009/07/Scheutz_mechanical_calculator_small.png" alt="Scheutz Mechanical Calculator" width="335" height="176" /></a><p class="wp-caption-text">The Scheutz Mechanical Calculator</p></div>
<p>Hi everyone,</p>
<p>A SourceHosting.net client recently asked to create a large number of users in a custom installation of <a href="http://www.phpdeadlock.org/" target="_blank">phpDeadlock</a> that he uses to manage access to his <a href="http://www.sourcehosting.net/solutions.php" target="_blank">Subversion repository</a> here. Since phpDeadlock doesn&#8217;t have a user management API, this sounded like a monotonous, error-prone task.  After entering 10-15 users, the chances of misspelling a name or email address or clicking the wrong button in the UI will likely increase dramatically.</p>
<p>I briefly investigated adding records directly to the backend MySQL database, but since various other actions are fired by user creation, including email notifications to the new user and the system administrator, using the application&#8217;s UI was the safest choice.</p>
<p>I had run across the <a href="http://search.cpan.org/dist/WWW-Mechanize/" target="_blank">WWW::Mechanize</a> Perl module a while back, but hadn&#8217;t used it yet. I knew it could be used to automate interaction with a web site, and after reading through the <a href="http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm" target="_blank">rich list of methods</a>, I promptly began hacking a script together to parse a list of email addresses supplied by the client and use it to drive the user creation UI.</p>
<p>The module implements a headless web browser, including cookie jar, history, form submission and other behaviors that you would expect, except it doesn&#8217;t parse and execute Javascript. That was a non-issue for me.</p>
<p>phpDeadlock has an administrator login prompt that requests a password before any privileged pages are accessed. Logging in to the application was a no-brainer in WWW::Mechanize:</p>
<p><pre><pre>
use WWW::Mechanize;
use String::Random;
use Text::Capitalize;

my $mech = WWW::Mechanize-&gt;new();
$mech-&gt;get(&#039;https://phpdeadlock.mydomain.com/admin/&#039;);
$mech-&gt;set_visible(&#039;ItsASecret&#039;);
$mech-&gt;submit_form();
</pre></pre></p>
<p>That was too easy! All further page requests will be authenticated. Next, the script enters a loop to process email addresses presented on STDIN, one per line, and populate the required fields:</p>
<p><pre><pre>
for my $email (&lt;STDIN&gt;) {
&nbsp;&nbsp;&nbsp;&nbsp;chomp $email;
&nbsp;&nbsp;&nbsp;&nbsp;my @fields = split /\@/, $email;
&nbsp;&nbsp;&nbsp;&nbsp;my $finitial = substr($fields[0], 0, 1);
&nbsp;&nbsp;&nbsp;&nbsp;my $lname = substr($fields[0], 1);
&nbsp;&nbsp;&nbsp;&nbsp;my $pw = new String::Random-&gt;randpattern(&quot;ssssssss&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;$mech-&gt;get(&#039;https://phpdeadlock.mydomain.com/admin/newuser.php&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;$mech-&gt;submit_form(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fields =&gt; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;firstname =&gt; capitalize($finitial),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lastname =&gt; capitalize($lname),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;email =&gt; $email,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username =&gt; $fields[0],
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password =&gt; $pw,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password2 =&gt; $pw
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Added new user for $finitial $lname\n&quot;;
}
</pre></pre></p>
<p>If the user&#8217;s full name had been supplied, I could have easily parsed that and set the firstname and lastname fields appropriately.</p>
<p>The possibilities for using this module are endless, and I encourage you to try it out, especially when you&#8217;re dreading a repetitive web application UI task.  Make sure to check the list of other Perl modules that are <a href="http://search.cpan.org/search?query=mechanize&amp;mode=all" target="_blank">based on WWW::Mechanize</a>, too!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2009/07/17/perl-www-mechanize-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improving PHP Application Performance</title>
		<link>http://blog.sourcehosting.net/2009/07/16/php-application-optimization/</link>
		<comments>http://blog.sourcehosting.net/2009/07/16/php-application-optimization/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 13:47:50 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/?p=191</guid>
		<description><![CDATA[Hi everyone, I came across a helpful list of PHP optimization tips, and I&#8217;d like to share it with you here: http://php100.wordpress.com/2009/07/13/php-performance/ In addition, using the XDebug profiler for collecting performance data and KCacheGrind for viewing it is highly recommended to keep your PHP applications running smoothly!]]></description>
			<content:encoded><![CDATA[<div id="attachment_194" class="wp-caption alignright" style="width: 266px"><a href="http://flickr.com/photos/12169388@N05"><img class="size-full wp-image-194" title="High-Performance PHP" src="http://www.sourcehosting.net/blog-media/2009/07/tmpphpIHRihQ.jpg" alt="Photo by: Mark McArdle" width="256" height="147" /></a><p class="wp-caption-text">Photo by: Mark McArdle</p></div>
<p>Hi everyone,</p>
<p>I came across a helpful list of PHP optimization tips, and I&#8217;d like to share it with you here: <a href="http://php100.wordpress.com/2009/07/13/php-performance/" target="_blank">http://php100.wordpress.com/2009/07/13/php-performance/</a></p>
<p>In addition, using the <a href="http://xdebug.org/docs/profiler" target="_blank">XDebug profiler</a> for collecting performance data and <a href="http://kcachegrind.sourceforge.net/html/Home.html" target="_blank">KCacheGrind</a> for viewing it is highly recommended to keep your PHP applications running smoothly!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2009/07/16/php-application-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Views In CodeIgniter</title>
		<link>http://blog.sourcehosting.net/2008/03/07/rendering-views-in-codeigniter/</link>
		<comments>http://blog.sourcehosting.net/2008/03/07/rendering-views-in-codeigniter/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 20:24:53 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/03/07/rendering-views-in-codeigniter/</guid>
		<description><![CDATA[Hi everyone, A while back, I hooked up my CodeIgniter sample application to a MySQL database. That was easy, and now I&#8217;ll show how to move your presentation code into separate view files, instead of echo&#8217;ing HTML from inside a controller file. According to the CodeIgniter manual, views are stored in the /views (hmm, that [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p><a href="http://blog.sourcehosting.net/2008/02/20/hooking-codeigniter-to-mysql/">A while back</a>, I hooked up my CodeIgniter sample application to a MySQL database. That was easy, and now I&#8217;ll show how to move your presentation code into separate view files, instead of echo&#8217;ing HTML from inside a controller file.</p>
<p>According to the <a href="http://codeigniter.com/user_guide/general/views.html" target="_blank">CodeIgniter manual</a>, views are stored in the <code>/views</code> (hmm, that makes sense!) directory of your application, and they can be divided up across functional areas with subdirectories. Since it&#8217;s possible to create page snippets and load them in sequence, you might have a directory structure like this:<br />
<pre><pre>
/views
&nbsp;&nbsp;/global
&nbsp;&nbsp;&nbsp;&nbsp;/layout
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/header.php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/footer.php
&nbsp;&nbsp;/navigation
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/left_side.php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/bottom_links.php
&nbsp;&nbsp;/user
&nbsp;&nbsp;&nbsp;&nbsp;/add.php
&nbsp;&nbsp;&nbsp;&nbsp;/edit.php
&nbsp;&nbsp;&nbsp;&nbsp;/delete.php
&nbsp;&nbsp;&nbsp;&nbsp;...
&nbsp;&nbsp;/group
&nbsp;&nbsp;&nbsp;&nbsp;/add.php
&nbsp;&nbsp;&nbsp;&nbsp;/edit.php
&nbsp;&nbsp;&nbsp;&nbsp;/delete.php
&nbsp;&nbsp;&nbsp;&nbsp;...
&nbsp;&nbsp;/...
&nbsp;&nbsp;/...</pre></pre><br />
Then when you want to render a particular page, say the &#8220;add user&#8221; page of your web app&#8217;s administrative interface, the code would look like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;global/layout/header.php&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;global/navigation/left_side.php&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;user/add.php&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;global/navigation/bottom_links.php&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;global/layout/footer.php&#8217;</span><span class="br0">&#41;</span>;</div>
<p>I haven&#8217;t gotten that complex yet, but I did move the code to display my user count into a view and set the value in the controller like so:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> count_users<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$numUsers</span> = <span class="re0">$this</span>-&gt;<span class="me1">user</span>-&gt;<span class="me1">count_users</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$data</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;num_users&#8217;</span> =&gt; <span class="re0">$numUsers</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;user/showcount&#8217;</span>, <span class="re0">$data</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>The file <code>/views/user/showcount.php</code> is pretty simple:</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;html&gt;<br />
&lt;head&gt;&lt;title&gt;Welcome to the User Area!&lt;/title&gt;&lt;/head&gt;<br />
&lt;body&gt;<br />
This page is rendered by the file: &lt;?php echo __FILE__; ?&gt;<br />
&lt;p&gt;There are &lt;?php echo $num_users; ?&gt; users defined in the database.<br />
&lt;p&gt;&lt;?php echo anchor(&#8216;user&#8217;, &#8216;Go back&#8217;); ?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Ok, this all seems to be pretty easy. Of course, there&#8217;s a bunch more functionality in the CodeIgniter framework, but I think what I&#8217;ll do for my next post is shift gears and go through the same basic exercises using CakePHP, Prado, and the Zend Framework.</p>
<p>It will be interesting to see if there&#8217;s any similarity to the way the classic &#8220;Hello, world.&#8221; program varies in complexity <a href="http://www.roesler-ac.de/wolfram/hello.htm" target="_blank">based on implementation language</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/03/07/rendering-views-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD Port For CodeIgniter Upgraded to 1.6.1</title>
		<link>http://blog.sourcehosting.net/2008/03/06/freebsd-port-codeigniter-161/</link>
		<comments>http://blog.sourcehosting.net/2008/03/06/freebsd-port-codeigniter-161/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 00:01:05 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/03/06/freebsd-port-codeigniter-161/</guid>
		<description><![CDATA[Hi everyone, I&#8217;ve submitted some new FreeBSD port upgrades over the past week, including new support for CodeIgniter 1.6.1. In addition to the version bump of the upstream distribution, I also added some new bits to allow customization of certain CI files. The port is also careful to avoid removing those modified files when a [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>I&#8217;ve submitted some new FreeBSD port upgrades over the past week, including new support for CodeIgniter 1.6.1. In addition to the version bump of the upstream distribution, I also added some new bits to allow customization of certain CI files. The port is also careful to avoid removing those modified files when a new port upgrade comes along.</p>
<p>The reference for how to handle user-configurable files installed as part of a port can be found in the excellent <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/" target="_blank">FreeBSD Porter&#8217;s Handbook</a> in the <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/plist-config.html" target="_blank">Configuration Files section</a>.</p>
<p>In the new CodeIgniter port, the following user-configurable files are installed:<br />
<pre><code>
&amp;lt;INSTALL_DIR&amp;gt;/index.php
&amp;lt;INSTALL_DIR&amp;gt;/index.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/autoload.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/autoload.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/config.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/config.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/database.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/database.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/hooks.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/hooks.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/mimes.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/mimes.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/routes.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/routes.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/smileys.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/smileys.php.sample
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/user_agents.php
&amp;lt;INSTALL_DIR&amp;gt;/system/application/config/user_agents.php.sample
</code></pre></p>
<p>What this does is install a reference copy of each file (*.sample) that is not expected to be edited by the user.  The actual file that CodeIgniter uses to render pages (no .sample suffix) is user-configurable as needed.</p>
<p>Then some crazy-looking shell code in the <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/porting-desc.html#AEN99" target="_blank">pkg-plist file</a> makes sure that any edited files are not removed if the port is deinstalled or upgraded (reformatted for readability):</p>
<div class="dean_ch" style="white-space: wrap;">@unexec <span class="kw1">if</span> <span class="kw2">cmp</span> -s %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php.sample \</p>
<p>&nbsp; &nbsp; %D/%%WWWDIR%/%%CI_CONF_DIR%%/autoload.php; <span class="kw1">then</span> \</p>
<p>&nbsp; &nbsp; <span class="kw2">rm</span> -f %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php; <span class="kw1">else</span> \</p>
<p>&nbsp; &nbsp; %%ECHO_MSG%% <span class="st0">&quot;===&gt; Customized %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php <span class="es0">\</span></p>
<p>&nbsp; &nbsp; has not been removed&quot;</span>; <span class="kw1">fi</span></p>
<p>%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php.sample</p>
<p>@<span class="kw3">exec</span> <span class="kw1">if</span> <span class="br0">&#91;</span> ! -f %D/%%WWWDIR%%/%%CI_CONF_DIR%%/autoload.php <span class="br0">&#93;</span>; <span class="kw1">then</span> \</p>
<p>&nbsp; &nbsp; <span class="kw2">cp</span> -p %D/%F %B/autoload.php; <span class="kw1">fi</span></div>
<p>This concept needs to be implemented in several of the other ports that I maintain, including <a href="http://www.freshports.org/www/cakephp/" target="_blank">CakePHP</a> and <a href="http://www.freshports.org/www/prado/" target="_blank">Prado</a>. If anyone has a list of files that are user-configurable in each of those frameworks, please send it along!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/03/06/freebsd-port-codeigniter-161/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hooking My CodeIgniter Application to MySQL</title>
		<link>http://blog.sourcehosting.net/2008/02/20/hooking-codeigniter-to-mysql/</link>
		<comments>http://blog.sourcehosting.net/2008/02/20/hooking-codeigniter-to-mysql/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 00:19:45 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/02/20/hooking-codeigniter-to-mysql/</guid>
		<description><![CDATA[Hi everyone, When I last posted about my sample application development with CodeIgniter, I had created a simple Hello, World application. The next thing I want to explore is how easy it is to connect to a MySQL database and retrieve data. As a quick side note, the CodeIgniter User Guide is well-written and very [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>When I last posted about my sample application development with CodeIgniter, I had created a simple Hello, World application. The next thing I want to explore is how easy it is to connect to a MySQL database and retrieve data.</p>
<p>As a quick side note, the <a href="http://codeigniter.com/user_guide/" target="_blank">CodeIgniter User Guide</a> is well-written and very clear with plenty of examples.  That&#8217;s always nice to see and instills some confidence in the quality of the underlying code.</p>
<p>According to the guide, all of the database connections should be defined in the <code>application/config/database.php</code> file. After setting up a new database named &#8220;ci&#8221; and a database user, I opened <code>database.php</code> and set up my connection:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;hostname&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;localhost&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;username&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;ci&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;password&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;ci&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;database&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;ci&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;dbdriver&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;mysql&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;dbprefix&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;&quot;</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;active_r&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">TRUE</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;pconnect&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">TRUE</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;db_debug&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">TRUE</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;cache_on&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">FALSE</span>;<br />
<span class="re0">$db</span><span class="br0">&#91;</span><span class="st0">&#8216;default&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;cachedir&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;&quot;</span>;</div>
<p>That was easy enough.  Now I&#8217;ve got the skeleton of a model defined in <code>application/models/user_model.php</code>:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">class</span> Group_model <span class="kw2">extends</span> Model <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">function</span> Group_model<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent::<span class="me2">Model</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">database</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>The <code>$this-&amp;gt;load-&amp;gt;database()</code> statement automatically connects to MySQL using the default connection I defined previously. Now I can use the <code>$this-&amp;gt;db</code> object to run queries and process results elsewhere in my model file.</p>
<p>I&#8217;ll replace my original hard-coded count_users function with something that runs an actual database query:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> count_users<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$query</span> = <span class="re0">$this</span>-&gt;<span class="me1">db</span>-&gt;<span class="me1">query</span><span class="br0">&#40;</span><span class="st0">&#8216;SELECT COUNT(*) AS num_users FROM user&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$query</span>-&gt;<span class="me1">num_rows</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$query</span>-&gt;<span class="me1">row</span><span class="br0">&#40;</span><span class="br0">&#41;</span>-&gt;<span class="me1">num_users</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>Of course, I have to leave a newbie coding error in there for someone to notice. <a href="http://www.imdb.com/title/tt0091042/" target="_blank">Anyone? Anyone? Bueller?</a></p>
<p>Here&#8217;s my simple MySQL database schema:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">&#8211;</span><br />
<span class="co1">&#8211; Table structure for table `user`</span><br />
<span class="co1">&#8211;</span></p>
<p><span class="kw1">CREATE TABLE</span> IF <span class="kw3">NOT</span> <span class="kw1">EXISTS</span> `user` <span class="br0">&#40;</span><br />
`id` <span class="kw2">INT</span><span class="br0">&#40;</span><span class="nu0">11</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span> <span class="kw3">AUTO_INCREMENT</span>,<br />
`user_name` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">128</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
`full_name` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">128</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
`email` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">128</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
<span class="kw1">PRIMARY KEY</span> &nbsp;<span class="br0">&#40;</span>`id`<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE=MyISAM &nbsp;<span class="kw3">DEFAULT</span> <span class="kw3">CHARSET</span>=latin1 <span class="kw3">AUTO_INCREMENT</span>=<span class="nu0">3</span> ;</p>
<p><span class="co1">&#8211;</span><br />
<span class="co1">&#8211; Dumping data for table `user`</span><br />
<span class="co1">&#8211;</span></p>
<p><span class="kw1">INSERT</span> <span class="kw1">INTO</span> `user` <span class="br0">&#40;</span>`id`, `user_name`, `full_name`, `email`<span class="br0">&#41;</span> <span class="kw1">VALUES</span><br />
<span class="br0">&#40;</span><span class="nu0">1</span>, <span class="st0">&#8216;glarkin&#8217;</span>, <span class="st0">&#8216;Greg Larkin&#8217;</span>, <span class="st0">&#8216;glarkin@sourcehosting.net&#8217;</span><span class="br0">&#41;</span>,<br />
<span class="br0">&#40;</span><span class="nu0">2</span>, <span class="st0">&#8216;morsel&#8217;</span>, <span class="st0">&#8216;Morsel The Cat&#8217;</span>, <span class="st0">&#8216;morsel@meow.com&#8217;</span><span class="br0">&#41;</span>;</div>
<p>When I navigate to my <code>/codeigniter/user/count_users/</code> URL, I see:</p>
<p><code>There are 2 users defined</code></p>
<p>Great! Next up, we&#8217;ll take a look at creating an actual output page with views.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/02/20/hooking-codeigniter-to-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter 1.6.1 Is Released</title>
		<link>http://blog.sourcehosting.net/2008/02/15/codeigniter-161-released/</link>
		<comments>http://blog.sourcehosting.net/2008/02/15/codeigniter-161-released/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 21:31:51 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/02/15/codeigniter-161-released/</guid>
		<description><![CDATA[Hi everyone, I just saw that CodeIgniter 1.6.1 has been released. I guess that means I&#8217;d better get on the stick and upgrade the FreeBSD CodeIgniter port! Once I do that, I&#8217;ll upgrade my PHP Framework VM with the new version of the port and continue on with the experimentation.]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>I just saw that <a href="http://codeigniter.com/news/codeigniter_161_released/" target="_blank">CodeIgniter 1.6.1 has been released</a>. I guess that means I&#8217;d better get on the stick and upgrade the <a href="http://www.freshports.org/www/codeigniter/" target="_blank">FreeBSD CodeIgniter port</a>! Once I do that, I&#8217;ll upgrade my PHP Framework VM with the new version of the port and continue on with the experimentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/02/15/codeigniter-161-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diving Into CodeIgniter</title>
		<link>http://blog.sourcehosting.net/2008/02/08/diving-into-codeigniter/</link>
		<comments>http://blog.sourcehosting.net/2008/02/08/diving-into-codeigniter/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 22:19:06 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/02/08/diving-into-codeigniter/</guid>
		<description><![CDATA[Hi everyone, Now that I&#8217;ve got my FreeBSD virtual machine set up with the various PHP frameworks, it&#8217;s time to start putting together a sample application in each one to learn their strengths and weaknesses. The sample application will be a simple mailing list manager and contain common features such as: User account self-registration Email [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>Now that I&#8217;ve got my FreeBSD virtual machine set up with the various PHP frameworks, it&#8217;s time to start putting together a sample application in each one to learn their strengths and weaknesses. The sample application will be a simple mailing list manager and contain common features such as:</p>
<ul>
<li>User account self-registration</li>
<li>Email generation</li>
<li>Management interface</li>
<li>MySQL database backend</li>
</ul>
<p>I think that will exercise enough of each framework to get a good handle on their functionality and ease of use.<br />
I&#8217;m starting off with <a href="http://www.codeigniter.com/" target="_blank">CodeIgniter</a>. At first glance, the documentation seems excellent, and the code is commented very clearly. Looking at the <code>index.php</code> file in the root installation directory (<code>/usr/local/www/codeigniter</code> on FreeBSD), I see:</p>
<div class="dean_ch" style="white-space: wrap;">
/*<br />
|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
| APPLICATION FOLDER NAME<br />
|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
|<br />
| If you want this front controller to use a different &quot;application&quot;<br />
| folder then the default one you can set its name here. The folder<br />
| can also be renamed or relocated anywhere on your server.<br />
| For more info please see the user guide:<br />
| http://www.codeigniter.com/user_guide/general/managing_apps.html<br />
|<br />
|<br />
| NO TRAILING SLASH!<br />
|<br />
*/<br />
$application_folder = &quot;application&quot;;<br />
&nbsp;</div>
<p>Ok, that seems easy enough. To keep the default application intact and start working on my custom application, I simply copied the existing application directory to <code>/usr/local/www/ci_sourcehosting</code> and updated the <code>index.php</code> file.</p>
<div class="dean_ch" style="white-space: wrap;">
$application_folder = &quot;/usr/local/www/ci_sourcehosting&quot;;<br />
&nbsp;</div>
<p>According to the welcome page displayed by CodeIgniter, I have to change the <code>views/welcome_message.php</code> file to change the default page contents. Ok, easy enough&#8230;</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/02/codeigniter-my-hello-world.png" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=29&amp;r=0.3519313304721&amp;w=400&amp;h=246' alt='Custom Hello World on CodeIgniter' width='400' height='246' /></a></p>
<p>The <code>controllers/welcome.php</code> controller is called by default, and that&#8217;s configured in the <code>config/routes.php</code> file in your application directory.</p>
<p>To create a new controller, simply create a new class that extends Controller and name it with a capital letter. Save the new class to the lowercase version of the class name into the <code>/controllers</code> directory, and you&#8217;re ready to test.</p>
<p>My simple class is:</p>
<div class="dean_ch" style="white-space: wrap;">
class User extends Controller {<br />
&nbsp; &nbsp; function index()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &#8216;Welcome to the user controller&#8217;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; function count-users()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &#8216;There are 0 users defined&#8217;;<br />
&nbsp; &nbsp; }<br />
}<br />
&nbsp;</div>
<p>When I visit <code>http://192.168.95.128/codeigniter/user</code>, I see:</p>
<p><code>Welcome to the user controller</code></p>
<p>and <code>http://192.168.95.128/codeigniter/user/count-users</code> displays:</p>
<p><code>There are 0 users defined</code></p>
<p>Ok, that&#8217;s pretty straightforward, but I did have to do a bit of mucking about to get the URLs to look like <code>http://192.168.95.128/codeigniter/user/count</code> instead of <code>http://192.168.95.128/&lt;strong&gt;index.php&lt;/strong&gt;/codeigniter/user/count</code>.</p>
<p>The CodeIgniter manual specifies a .htaccess file to be placed in the directory where the index.php front controller is located:</p>
<div class="dean_ch" style="white-space: wrap;">
RewriteEngine on<br />
RewriteCond $1 !^(index.php|images|robots.txt)<br />
RewriteRule ^(.*)$ /index.php/$1 [L]<br />
&nbsp;</div>
<p>Normally, this works fine, except Apache 2.2 specifies <code>AllowOverride None</code> by default, so .htaccess files don&#8217;t work. After changing that, I had to make one small change to the .htaccess file, since my CodeIgniter installation is rooted at <code>/codeigniter</code>:</p>
<div class="dean_ch" style="white-space: wrap;">
RewriteRule ^(.*)$ /codeigniter/index.php/$1 [L]<br />
&nbsp;</div>
<p>Next time, we&#8217;ll take a look at hooking CodeIgniter to MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/02/08/diving-into-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PHP Frameworks with the FreeBSD Ports Tree</title>
		<link>http://blog.sourcehosting.net/2008/02/01/freebsd-cakephp-installation/</link>
		<comments>http://blog.sourcehosting.net/2008/02/01/freebsd-cakephp-installation/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 16:21:51 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/02/01/freebsd-cakephp-installation/</guid>
		<description><![CDATA[Hi everyone, Ok, let&#8217;s proceed to install the various PHP frameworks that we&#8217;ll use to create a sample application. As I mentioned in a previous post, the basic command for installing any port in the tree is: cd /usr/ports/&#38;lt;category&#38;gt;/&#38;lt;appname&#38;gt; &#38;amp;&#38;amp; make install clean Let&#8217;s start with the CakePHP framework: cd /usr/ports/www/cakephp &#38;amp;&#38;amp; make install clean [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>Ok, let&#8217;s proceed to install the various PHP frameworks that we&#8217;ll use to create a sample application.</p>
<p>As I mentioned in a previous post, the basic command for installing any port in the tree is:<br />
<pre>cd /usr/ports/&amp;lt;category&amp;gt;/&amp;lt;appname&amp;gt; &amp;amp;&amp;amp; make install clean</pre><br />
Let&#8217;s start with the <a href="http://www.cakephp.org/" target="_blank">CakePHP framework</a>:<br />
<pre>cd /usr/ports/www/cakephp &amp;amp;&amp;amp; make install clean</pre><br />
After typing that command, you should see this on the screen:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/make-install-options.png" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=19&amp;r=0.54094827586207&amp;w=400&amp;h=251' alt='FreeBSD Port Installation Options' width='400' height='251' /></a></p>
<p>Hmm, what is that screen for? The FreeBSD ports collection has a robust infrastructure for configuring software applications prior to installation. In this case, CakePHP works with multiple different database backends, so the port writer (i.e. <a href="http://www.linkedin.com/in/greglarkin" target="_blank">me</a>) decided to provide options so the prerequisite bits are installed before the port proper.</p>
<p>Looking at the options provided here, the first one named &#8220;PROD&#8221; determines the way that the Apache web server is configured for CakePHP. If this is a production server, this option should be selected so navigating to &#8220;http://&lt;servername&gt;/&#8221; displays the CakePHP welcome page.  Since I am installing multiple frameworks on the same machine, I&#8217;ll leave this option unchecked. That way, each framework welcome page will be found at &#8220;http://&lt;servername&gt;/&lt;frameworkname&gt;/&#8221;.</p>
<p>I plan to use MySQL as a database backend, so the following screenshot shows the MYSQL option selected. The dialog box is navigated with the tab and arrow keys on your keyboard, and the spacebar toggles the option selections:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/make-install-options-mysql.png" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=20&amp;r=0.54094827586207&amp;w=400&amp;h=251' alt='FreeBSD Port MySQL Option' width='400' height='251' /></a></p>
<p>Tab to the OK button and hit Enter, and the port build starts. Here is the full transcript of the process:</p>
<a rel="nofollow" title="Download version 0.1 of cakephp.log" onclick="if (window.urchinTracker) urchinTracker ('http://blog.sourcehosting.net/downloads/2008/02/cakephp.log');" href="http://blog.sourcehosting.net/downloads/2008/02/cakephp.log">CakePHP Port Build Transcript</a>
<p>Notice that by selecting the MYSQL option prior to installation, the port build fetched and built the MySQL client library and the PHP MySQL module, as well as some other packages:</p>
<p>mysql-client-5.0.51<br />
php5-pcre-5.2.5_1<br />
php5-pdo-5.2.5_1<br />
php5-pdo_mysql-5.2.5_1<br />
php5-session-5.2.5_1</p>
<p>This helps us get a working PHP installation that supports CakePHP out of the box.</p>
<p>Now, it&#8217;s the moment of truth &#8211; does the CakePHP default page display correctly?  In order to load the page on your host machine, find the VM&#8217;s IP address with the following command:<br />
<pre>/sbin/ifconfig -a | grep -w inet | grep -v 127.0.0.1 | awk &#039;{ print $2 }&#039;</pre><br />
That gives me 192.168.95.128, so here&#8217;s the URL where I should find the CakePHP default page: http://192.168.95.128/cakephp/. The address will likely be different for you.</p>
<p>This looks good!</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/02/cakephp-default.png" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=25&amp;r=0.39084967320261&amp;w=400&amp;h=299' alt='CakePHP Default Page' width='400' height='299' /></a></p>
<p>Now as an exercise for the reader, try installing the rest of the frameworks and make sure that they display their welcome pages:</p>
<p><a href="http://www.freshports.org/www/codeigniter/" target="_blank">CodeIgniter</a><br />
<a href="http://www.freshports.org/www/prado/" target="_blank">PRADO</a><br />
<a href="http://www.freshports.org/www/zend-framework/" target="_blank">Zend Framework</a></p>
<p>If you have any trouble, write in with comments and feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/02/01/freebsd-cakephp-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update the FreeBSD Ports Tree</title>
		<link>http://blog.sourcehosting.net/2008/01/28/freebsd-portsnap-sample-run/</link>
		<comments>http://blog.sourcehosting.net/2008/01/28/freebsd-portsnap-sample-run/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 19:18:42 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[portsnap]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/01/28/freebsd-portsnap-sample-run/</guid>
		<description><![CDATA[Hi everyone, Now that we&#8217;ve got the FreeBSD 6.2 VM booted up under VMware Player or VMware Server, we need to make sure that we&#8217;ve got the latest version of the ports tree installed. Since you may be reading this well after I build the original VM image, the FreeBSD ports tree has probably changed [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>Now that we&#8217;ve got the FreeBSD 6.2 VM booted up under VMware Player or VMware Server,  we need to make sure that we&#8217;ve got the latest version of the ports tree installed. Since you may be reading this well after I build the original VM image, the <a href="http://www.freebsd.org/ports/" target="_blank">FreeBSD ports tree</a> has probably changed a lot, and it&#8217;s possible that new versions of the PHP frameworks are available.</p>
<p>First of all, what is the ports tree? Quite simply, it&#8217;s a large collection of directories (18,000+ at last count!), one for every 3rd party software package that has been ported to FreeBSD. What does this gain you? The idea is that any piece of ported software can be installed on your FreeBSD system as easily as typing the following command in the appropriate directory:<br />
<pre>cd /usr/ports/&amp;lt;category&amp;gt;/&amp;lt;appname&amp;gt; &amp;amp;&amp;amp; make install clean</pre><br />
e.g.<br />
<pre>cd /usr/ports/databases/mysql50-server &amp;amp;&amp;amp; make install clean</pre><br />
That&#8217;s it! The same command will install anything from a simple Perl module to the Java development kit.</p>
<p>The command to update your FreeBSD VM with the latest ports tree is equally simple. Log in as root and type the following:<br />
<pre>portsnap fetch update</pre><br />
You&#8217;ll see some output like this:</p>
<a rel="nofollow" title="Download version 0.1 of portsnap.log" onclick="if (window.urchinTracker) urchinTracker ('http://blog.sourcehosting.net/downloads/2008/01/portsnap.log');" href="http://blog.sourcehosting.net/downloads/2008/01/portsnap.log">Sample FreeBSD portsnap run</a>
<p>Now we&#8217;re ready to install some PHP frameworks, but that&#8217;s a post for another day!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/01/28/freebsd-portsnap-sample-run/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Booting Your First VMware Virtual Machine</title>
		<link>http://blog.sourcehosting.net/2008/01/25/boot-a-vmware-virtual-machine/</link>
		<comments>http://blog.sourcehosting.net/2008/01/25/boot-a-vmware-virtual-machine/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 16:13:57 +0000</pubDate>
		<dc:creator>Greg Larkin</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[virtual appliance]]></category>
		<category><![CDATA[virtual machine]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://blog.sourcehosting.net/2008/01/25/boot-a-vmware-virtual-machine/</guid>
		<description><![CDATA[Hello everyone, Now that we&#8217;ve got some example virtual machines to play around with, let&#8217;s move on to the next step and get one running. I&#8217;m using VMware Player on Windows XP, and the VM files have been extracted to My Documents\My Virtual Machines. The folder contents look like this: Digging into the VM installation [...]]]></description>
			<content:encoded><![CDATA[<p>Hello everyone,</p>
<p>Now that we&#8217;ve got some <a href="http://torrents.sourcehosting.net:10692/torrents/FreeBSD+6.2+Basic+Installation+-+Bare+Bones.zip.torrent?CEFC37315130C147CE7D8B4B63F30BEB939C5B81" target="_blank">example virtual machines</a> to <a href="http://torrents.sourcehosting.net:10692/torrents/FreeBSD+6.2+Basic+Installation+-+Apache+2.2+%2B+PHP+5.2.5.zip.torrent?58AB0331EA8BAA4AD50EB103B428A8E52F13884B" target="_blank">play around with</a>, let&#8217;s move on to the next step and get one running.</p>
<p>I&#8217;m using <a href="http://www.vmware.com/products/player/" target="_blank">VMware Player</a> on Windows XP, and the VM files have been extracted to My Documents\My Virtual Machines. The folder contents look like this:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/vmware-installation-directory.png" target="_blank" title="VMware Installation Directory"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=11&amp;r=0.5&amp;w=400&amp;h=300' alt='VMware Installation Directory' width='400' height='300' /></a></p>
<p>Digging into the VM installation directory proper, you see all of the files that make up your  virtual machine:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/virtual-machine-directory.png" title="Virtual Machine Directory" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=12&amp;r=0.5&amp;w=400&amp;h=300' alt='Virtual Machine Directory' width='400' height='300' /></a></p>
<p>The .vmx file is a text file that contains all of the virtual machine configuration options. You can change the VM memory allocation, add/remove devices, etc. just by editing that file. The .vmdk files are the virtual machine&#8217;s disks and store its state across reboots.</p>
<p>If your VM ever runs out of disk space and you still have room on your host operating system, you can create additional vmdk files and attach them to the VM. That sure is easier than cracking open a server case and physically installing new drives!</p>
<p>Next, double-click on the <strong>FreeBSD 6.2 Basic Installation.vmx</strong> file, and VMware Player starts up and boots the VM:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/freebsd-boot-menu.png" title="FreeBSD Boot Menu" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=13&amp;r=0.54094827586207&amp;w=400&amp;h=251' alt='FreeBSD Boot Menu' width='400' height='251' /></a></p>
<p>After the usual messages, the virtual machine has booted, and you see the familiar UNIX login prompt:</p>
<p><a href="http://blog.sourcehosting.net/wp-content/uploads/2008/01/freebsd-boot-completion.png" title="FreeBSD Boot Completion" target="_blank"><img src='http://blog.sourcehosting.net/wp-content/plugins/power-thumbnail/show-image.php?type=resize&amp;id=14&amp;r=0.54094827586207&amp;w=400&amp;h=251' alt='FreeBSD Boot Completion' width='400' height='251' /></a></p>
<p>Next time, we&#8217;ll dive into installing the various PHP frameworks under FreeBSD. The FreeBSD ports system is designed for ease of use, and you&#8217;ll see how simple it is to get a software package and all of its dependencies installed with one command.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sourcehosting.net/2008/01/25/boot-a-vmware-virtual-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
