<?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>Andrew Havens Blog &#187; PHP</title>
	<atom:link href="http://blog.andrewhavens.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.andrewhavens.com</link>
	<description></description>
	<lastBuildDate>Mon, 14 Dec 2009 19:41:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to set up the Zend Framework Command Line Tool on Mac OS X</title>
		<link>http://blog.andrewhavens.com/2009/11/22/how-to-set-up-the-zend-framework-command-line-tool-on-mac-os-x/</link>
		<comments>http://blog.andrewhavens.com/2009/11/22/how-to-set-up-the-zend-framework-command-line-tool-on-mac-os-x/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 18:36:48 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Mac OS X 10.5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Tool CLI]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=142</guid>
		<description><![CDATA[ Now that the Zend Framework ships with a command line tool, it’s even easier to get started using the Zend Framework. In this tutorial, I will show you how to set up the command line tool for use on Mac OS X.
First, download the newest version of the Zend Framework. Both the full and [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F11%2F22%2Fhow-to-set-up-the-zend-framework-command-line-tool-on-mac-os-x%2F&amp;t=How+to+set+up+the+Zend+Framework+Command+Line+Tool+on+Mac+OS+X&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>Now that the Zend Framework ships with a command line tool, it’s even easier to get started using the Zend Framework. In this tutorial, I will show you how to set up the command line tool for use on Mac OS X.</p>
<p>First, <a href="http://framework.zend.com/download/latest">download the newest version of the Zend Framework</a>. Both the full and minimal versions come with the Command Line tool. For this tutorial, I will be using version 1.9.3.</p>
<p>Once the folder has downloaded, it will need to be extracted and moved somewhere you can find it. I will be moving this folder to the top level “/Library/” directory so it will be easy to type. Within the ZendFramework directory, there is a directory called bin. Within this directory is a file called zf.sh. This is the command line tool. So if you want to use the tool, open the Terminal application and navigate to the directory that you want your project created.</p>
<p>cd Sites</p>
<p>Then, type:</p>
<p>/Library/ZendFramework/bin/zf.sh create project InsertProjectNameHere</p>
<p>A new Zend Framework project will be created in the Sites directory with the name of InsertProjectNameHere. But this is more than I’d rather type on a regular basis, so we should create an alias. To create an alias, type the following:</p>
<p>alias zf=/Library/ZendFramework/bin/zf.sh</p>
<p>Now all we have to type is:</p>
<p>zf create project MyApp</p>
<p>That’s it! By running this command in the command line, we have just created a new Zend Framework project in the current directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/11/22/how-to-set-up-the-zend-framework-command-line-tool-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the best PHP mailing list software?</title>
		<link>http://blog.andrewhavens.com/2009/04/07/what-is-the-best-php-mailing-list-software/</link>
		<comments>http://blog.andrewhavens.com/2009/04/07/what-is-the-best-php-mailing-list-software/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 01:27:17 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mailing list software]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=126</guid>
		<description><![CDATA[ In my search for the best PHP mailing list software, I&#8217;ve come across some pretty bad ones, and some pretty good ones.
My criteria for a &#8220;good PHP mailing list&#8221; is the following:
-easy install
-easy integration
-double opt-in subscription
-sends mail even after browser window has closed (imagine waiting for your PHP script to finish sending an email [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F04%2F07%2Fwhat-is-the-best-php-mailing-list-software%2F&amp;t=What+is+the+best+PHP+mailing+list+software%3F&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>In my search for the best PHP mailing list software, I&#8217;ve come across some pretty bad ones, and some pretty good ones.</p>
<p>My criteria for a &#8220;good PHP mailing list&#8221; is the following:<br />
-easy install<br />
-easy integration<br />
-double opt-in subscription<br />
-sends mail even after browser window has closed (imagine waiting for your PHP script to finish sending an email to thousands of subscribers, one at a time).<br />
-customizable admin interface<br />
-open source (and free!)<br />
-not a hosted solution</p>
<p>That may be a dream, but I just found a new PHP mailing list that may meet the criteria. phplist.com may just do the trick. I will try it out and let you know what I think. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/04/07/what-is-the-best-php-mailing-list-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Zend_Test &#8211; Step 4: Testing your Zend Framework Controllers</title>
		<link>http://blog.andrewhavens.com/2009/03/13/getting-started-with-zend_test-step-4-testing-your-zend-framework-controllers/</link>
		<comments>http://blog.andrewhavens.com/2009/03/13/getting-started-with-zend_test-step-4-testing-your-zend-framework-controllers/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 18:56:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Test]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=100</guid>
		<description><![CDATA[ Finally! We can start testing our Controllers! I will assume that your application has the same directory structure as the Zend Framework Quick Start tutorial. Here&#8217;s an overview of what our directory structure will look like:
/myApp/application/controllers
/myApp/tests/application/controllers
Our tests directory will mirror our application. We might also include a &#8216;library&#8217; directory in the tests directory so [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F03%2F13%2Fgetting-started-with-zend_test-step-4-testing-your-zend-framework-controllers%2F&amp;t=Getting+started+with+Zend_Test+-+Step+4%3A+Testing+your+Zend+Framework+Controllers&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>Finally! We can start testing our Controllers! I will assume that your application has the same directory structure as the <a href="http://framework.zend.com/docs/quickstart">Zend Framework Quick Start tutorial</a>. Here&#8217;s an overview of what our directory structure will look like:</p>
<p>/myApp/application/controllers<br />
/myApp/tests/application/controllers</p>
<p>Our tests directory will mirror our application. We might also include a &#8216;library&#8217; directory in the tests directory so we can test our custom library components. For now, we&#8217;ll just keep it simple and test our controllers.</p>
<p>Now, we&#8217;ll create a file that will take care of auto loading. Create a new file called &#8216;loader.php&#8217; in you tests directory. All of our tests will require this file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library'</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span>
APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/models'</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span>
APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/forms'</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span>
<span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;Zend/Loader.php&quot;</span><span style="color: #339933;">;</span>
Zend_Loader<span style="color: #339933;">::</span><span style="color: #004000;">registerAutoload</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now let&#8217;s create a simple controller test. We&#8217;ll call this &#8216;IndexControllerTest.php&#8217; and put it in our tests/application/controllers directory. We just need to set the location of our bootstrap file. When <code>Zend_Test_PHPUnit_ControllerTestCase</code> constructs, it will look for the bootstrap file that we set here.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'../loader.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> IndexControllerTest <span style="color: #000000; font-weight: bold;">extends</span> Zend_Test_PHPUnit_ControllerTestCase
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'../../application/bootstrap.php'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testIndexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/index'</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;">assertController</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</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;">assertAction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</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;">assertResponseCode</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s it! All we have to do is run this file with our PHPUnit command line interface (that we used in the last tutorial).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/03/13/getting-started-with-zend_test-step-4-testing-your-zend-framework-controllers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting started with Zend_Test &#8211; Step 3: Make sure PHPUnit is ready for testing</title>
		<link>http://blog.andrewhavens.com/2009/03/11/getting-started-with-zend_test-step-3-make-sure-phpunit-is-ready-for-testing/</link>
		<comments>http://blog.andrewhavens.com/2009/03/11/getting-started-with-zend_test-step-3-make-sure-phpunit-is-ready-for-testing/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 03:56:24 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Test]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=95</guid>
		<description><![CDATA[ Now that we&#8217;ve installed PEAR and PHPUnit, we can verify that PHPUnit is working correctly by writing our first test.
Since we installed PHPUnit through PEAR, and we have properly configured our include_path variable in our php.ini file, we can create our test files anywhere and PHP will know where to look to find PHPUnit. [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F03%2F11%2Fgetting-started-with-zend_test-step-3-make-sure-phpunit-is-ready-for-testing%2F&amp;t=Getting+started+with+Zend_Test+-+Step+3%3A+Make+sure+PHPUnit+is+ready+for+testing&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>Now that we&#8217;ve installed PEAR and PHPUnit, we can verify that PHPUnit is working correctly by writing our first test.</p>
<p>Since we installed PHPUnit through PEAR, and we have properly configured our include_path variable in our php.ini file, we can create our test files anywhere and PHP will know where to look to find PHPUnit. So I will create a new file in my /Users/andrew/Sites directory and call it FoobarTest.php with the following contents:</p>
<pre class="brush: php;">

&lt;?php

class FoobarTest extends PHPUnit_Framework_TestCase {

public function testFoobar() {
$this-&gt;fail();
}

}
</pre>
<p>By writing our function name to start with &#8220;test&#8221;, PHPUnit will know to run this function as a test. Typically you will want to name your test functions with names similar to the functions that you are testing, preceded by &#8220;test&#8221;.</p>
<p>Now let&#8217;s run our test!</p>
<pre class="brush: cpp;">

cd /Users/andrew/Sites
phpunit FoobarTest.php
</pre>
<p>You should see something like the following:</p>
<pre class="brush: cpp;">

PHPUnit 3.3.15 by Sebastian Bergmann.

F

Time: 0 seconds

There was 1 failure:

1) testFoobar(FoobarTest)
/Users/andrew/Sites/FoobarTest.php:6

FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
</pre>
<p>Yay! It works! &#8220;But wait,&#8221; you say, &#8220;it says failures. Why is this a good thing?&#8221; Test-driven development is all about writing tests first. Remember this saying: Red, Green, Refactor. Start by writing the test, which will fail, of course, because you haven&#8217;t written any code yet! Then write the code until your test passes. Then STOP. There&#8217;s no need to keep writing. The code is finished. You know it works because you have the test to prove it. Tests are written to fail. Code is written to fix the tests.</p>
<p>However, this is a poor example of a test, so let&#8217;s write a real one.</p>
<p>Let&#8217;s start by thinking about what we want to build. How about we build a class called Foobar (to make things easy since we already have a FoobarTest) that has a function called getMessage(). However, getMessage() doesn&#8217;t return a string like we might expect, it returns an array. A test for that might look like the following. Also note that our function name is a little more verbose. Tests can serve as a sort of documentation. Think of underscores as commas and name your functions to explain what happens in the test.</p>
<pre class="brush: php;">

&lt;?php

class FoobarTest extends PHPUnit_Framework_TestCase {

public function testGetMessage_ReturnsAnArray() {
$foobar = new Foobar();
$message = $foobar-&gt;getMessage();
$this-&gt;assertTrue(is_array($message));
}

}
</pre>
<p>Now if we run our test again, we should see the following:</p>
<pre class="brush: cpp;">

PHPUnit 3.3.15 by Sebastian Bergmann.

PHP Fatal error:  Class 'Foobar' not found in /Users/andrew/Sites/FoobarTest.php on line 6

Fatal error: Class 'Foobar' not found in /Users/andrew/Sites/FoobarTest.php on line 6
</pre>
<p>Now we have an error that says PHPUnit can&#8217;t find our Foobar class. Well that&#8217;s because we haven&#8217;t created it yet! So create a new file in the same directory as our test, name it Foobar.php, and give it the following contents:</p>
<pre class="brush: php;">

&lt;?php

class Foobar {

}
</pre>
<p>Next, let&#8217;s update our test so it knows where to find our new class:</p>
<pre class="brush: php;">

&lt;?php

require_once('Foobar.php');

class FoobarTest extends PHPUnit_Framework_TestCase {

//...
</pre>
<p>That&#8217;s all we need to do. Remember, all we are trying to do is get the test to pass. Right now the test tells us that we need to create a Foobar class so that&#8217;s what we&#8217;ve done. Let&#8217;s run our test again and see what it says.</p>
<pre class="brush: cpp;">

HPUnit 3.3.15 by Sebastian Bergmann.

PHP Fatal error:  Call to undefined method Foobar::getMessage() in /Users/andrew/Sites/FoobarTest.php on line 9

Fatal error: Call to undefined method Foobar::getMessage() in /Users/andrew/Sites/FoobarTest.php on line 9
</pre>
<p>Hooray! We no longer have the same message as before. Now we need to create our getMessage() function in our Foobar class.</p>
<pre class="brush: php;">

&lt;?php

class Foobar {

public function getMessage() {

}

}
</pre>
<p>Run our test again and we should see another change:</p>
<pre class="brush: cpp;">

PHPUnit 3.3.15 by Sebastian Bergmann.

F

Time: 0 seconds

There was 1 failure:

1) testGetMessage_ReturnsAnArray(FoobarTest)
Failed asserting that &lt;boolean:false&gt; is true.
/Users/andrew/Sites/FoobarTest.php:10

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
</pre>
<p>getMessage() doesn&#8217;t return anything, so let&#8217;s change that:</p>
<pre class="brush: php;">

&lt;?php

class Foobar {

public function getMessage() {
return array();
}

}
</pre>
<p>That should be enough for us to get our test to pass. Let&#8217;s see if it works.</p>
<pre class="brush: cpp;">

PHPUnit 3.3.15 by Sebastian Bergmann.

.

Time: 0 seconds

OK (1 test, 1 assertion)
</pre>
<p>It works! We&#8217;re done. I think you get the picture. Let&#8217;s move on to some actual controller tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/03/11/getting-started-with-zend_test-step-3-make-sure-phpunit-is-ready-for-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Zend_Test &#8211; Step 1: Setting up PEAR on Mac OS X 10.5 (Leopard)</title>
		<link>http://blog.andrewhavens.com/2009/03/11/setting-up-pear-on-mac-os-x-105-leopard/</link>
		<comments>http://blog.andrewhavens.com/2009/03/11/setting-up-pear-on-mac-os-x-105-leopard/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 12:55:57 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Mac OS X 10.5]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Test]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=70</guid>
		<description><![CDATA[Question: How do I get started using Zend_Test? What is the process necessary to start using Zend_Test for testing my Zend Framework application?

Answer: Zend_Test extends PHPUnit. Therefore, we need to start by installing PHPUnit. The easiest way to install PHPUnit is by installing PEAR. Therefore...you get the idea. We need PEAR. I'll walk you through the process I took to install PEAR on Mac OS X 10.5 (Leopard).]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F03%2F11%2Fsetting-up-pear-on-mac-os-x-105-leopard%2F&amp;t=Getting+started+with+Zend_Test+-+Step+1%3A+Setting+up+PEAR+on+Mac+OS+X+10.5+%28Leopard%29&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p><strong>Question: </strong>How do I get started using Zend_Test? What is the process necessary to start using Zend_Test for testing my Zend Framework application?</p>
<p><strong>Answer:</strong> Zend_Test extends PHPUnit. Therefore, we need to start by installing PHPUnit. The easiest way to install PHPUnit is by installing PEAR. Therefore&#8230;you get the idea. We need PEAR. I&#8217;ll walk you through the process I took to install PEAR on Mac OS X 10.5 (Leopard).</p>
<p>Open up your trusty Terminal application by going to /Applications/Utilities.</p>
<p>First, we&#8217;ll switch over to a user that has enough permission to do anything, our super user:</p>
<pre class="brush: sql;">sudo su -</pre>
<p>Next, we&#8217;ll change directories to /usr/local by typing:</p>
<pre class="brush: cpp;">cd /usr/local</pre>
<p>Then, we&#8217;ll download and run the pear installer:</p>
<pre class="brush: sql;">curl http://pear.php.net/go-pear | php</pre>
<p>Press enter to begin the installation process. Press enter again to use no HTTP proxy. You should then see a screen with seven installation locations. The first one should say /usr/local. If this is not the case, press 1 and enter. Type /usr/local and press enter again. Now we should all be on the same page.</p>
<p>Press enter to continue with the installation. When asked, you can accept the additional PEAR packages by typing Y and pressing enter.</p>
<p>The installer will run through the installation, downloading and installing the necessary packages. Eventually the installation will finish. You may receive a warning that your php.ini file does not contain the PEAR PHP directory we specified (/usr/local/PEAR). This is okay. We will be editing this file in the next step. So simply type n and press enter. Press enter againto finish the installation. PEAR should now be installed and ready to use. Let&#8217;s see if it works by typing:</p>
<pre class="brush: sql;">pear version</pre>
<p>We should see a few lines including the version of PEAR we just installed, PHP version, etc. But wait, we&#8217;re not done yet! We still need to edit our php.ini file. If you don&#8217;t have a php.ini, you&#8217;ll need to create one by copying the php.ini.default:</p>
<pre class="brush: css;">cp /etc/php.ini.default /etc/php.ini</pre>
<p>Now were ready to edit our php.ini file. Open the file with Pico (or any other text editor):</p>
<pre class="brush: sql;">pico /etc/php.ini</pre>
<p>Scroll down about 1/3 and find the line that says:</p>
<pre class="brush: sql;">;include_path = “.:/php/includes”</pre>
<p>The semicolon at the beginning of the line means it&#8217;s commented out. Replace this line with the following:</p>
<pre class="brush: cpp;">include_path = “.:/usr/local/PEAR”</pre>
<p>Press Control + O, then enter, to save your changes. Then, Control + X to exit Pico. Restart your Apache server and you should be good to go!</p>
<pre class="brush: sql;">apachectl restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/03/11/setting-up-pear-on-mac-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to add password protection to a website</title>
		<link>http://blog.andrewhavens.com/2009/02/27/how-to-add-password-protection-to-a-website/</link>
		<comments>http://blog.andrewhavens.com/2009/02/27/how-to-add-password-protection-to-a-website/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 21:06:32 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[password protection]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=57</guid>
		<description><![CDATA[ Question: I have a website that I don&#8217;t want accessible to the general public. What is the best, most reliable and secure way to add password protection to my website (or section of my website) to make it secure?
Answer: there are a few different ways to add password protection to sites and pages: PHP, [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F02%2F27%2Fhow-to-add-password-protection-to-a-website%2F&amp;t=How+to+add+password+protection+to+a+website&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>Question: I have a website that I don&#8217;t want accessible to the general public. What is the best, most reliable and secure way to add password protection to my website (or section of my website) to make it secure?</p>
<p>Answer: there are a few different ways to add password protection to sites and pages: PHP, JavaScript, and htaccess. Depending on what you are trying to do with determine which method will be best for your application.</p>
<p>If I had a section of my website that was for members only (who I would like to sign up on my site), I would use PHP to manage the accounts created by the users, and logging users into the &#8220;members only&#8221; section of my website.</p>
<p>However, let&#8217;s look at a different case. Let&#8217;s say I&#8217;ve been developing a website for a client, locally, on my machine. Now I&#8217;m ready to show the client, but I don&#8217;t want the rest of the world to be able to see my &#8220;work in progress.&#8221; This is an example where htaccess would be best.</p>
<p>With htaccess, you will create a file on your server, telling your server to restrict access to only those people who provide the correct login credentials. Htaccess is EASY to set up and is among the most secure options available.</p>
<p>For a tutorial on how to set up htaccess, I found this tutorial to be quite helpful: <a href="http://www.javascriptkit.com/howto/htaccess3.shtml">Comprehensive Guide to .htaccess</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/02/27/how-to-add-password-protection-to-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>There&#8217;s a new IDE in town!</title>
		<link>http://blog.andrewhavens.com/2009/02/26/theres-a-new-ide-in-town/</link>
		<comments>http://blog.andrewhavens.com/2009/02/26/theres-a-new-ide-in-town/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 09:06:05 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[Espresso]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=51</guid>
		<description><![CDATA[ Now that I&#8217;m getting into Object Oriented PHP programming, and the Zend Framework, I need an editor that can keep up with the complexity of my projects. Integrated Development Environments can make developing websites go so much faster and more smoothly. I&#8217;ve been using Aptana for all of my PHP projects, but it just [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F02%2F26%2Ftheres-a-new-ide-in-town%2F&amp;t=There%27s+a+new+IDE+in+town%21&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p>Now that I&#8217;m getting into Object Oriented PHP programming, and the <a title="Zend Framework" href="http://framework.zend.com">Zend Framework</a>, I need an editor that can keep up with the complexity of my projects. Integrated Development Environments can make developing websites go so much faster and more smoothly. I&#8217;ve been using <a title="Aptana" href="http://www.aptana.com/php">Aptana</a> for all of my PHP projects, but it just feels bloated at times. Sometimes I just want a simple text editor and some FTP software. I decided to try <a title="TextMate" href="http://macromates.com/">TextMate</a>, the glorified Mac OS X text editor, and was relatively impressed but really wished there was some sort of integrated FTP functionality. At work, I&#8217;ve been using <a title="Subversion" href="http://subversion.tigris.org/">Subversion</a> to keep files in sync with my co-workers. I really like the &#8220;synchronize&#8221; feature of using Subversion, and really wish I could have some feature like that with FTP.</p>
<p>Well I recently came across an application called <a title="Espresso" href="http://macrabbit.com/espresso/">Espresso</a>. It&#8217;s in public beta right now, but so far, I am very impressed. The software is so simple and intuitive. I don&#8217;t know if you could technically call it an IDE, but it sure covers most of the features I use most of the time. It feels like TextMate, only simpler, with a bunch of integrated features like FTP, code completion, syntax highlighting, outline view, file search, live preview&#8230;the list goes on. My personal favorite is the &#8220;Publish&#8221; feature. This is like a mix of FTP and Subversion, making it possible to &#8220;synchronize&#8221; your local changes with the current state of your remote files. Again, this feature is so intuitive. It made it really easy to see which files I had changed, and allows me upload all my changes in a single click.</p>
<p>Another cool feature, is the ability to add extensions. These extensions are called Sugars (which you add to your Espresso. Clever, eh?). I can&#8217;t wait to see what sorts of Sugars are in the works!</p>
<p>I would definitely recommend checking out Espresso. Especially if you&#8217;re getting started with PHP programming, or want to get better at building websites. This may become a valuable tool that will help you learn faster and get things done easier.</p>
<p><strong>Update:</strong> <a href="http://macrabbit.com/espresso/">Espresso 1.0 has just been released!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/02/26/theres-a-new-ide-in-town/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set up Mac OS X 10.5 for Web Development</title>
		<link>http://blog.andrewhavens.com/2009/02/24/how-to-set-up-mac-os-x-105-for-web-development/</link>
		<comments>http://blog.andrewhavens.com/2009/02/24/how-to-set-up-mac-os-x-105-for-web-development/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 09:23:31 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Mac OS X 10.5]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Virtual Hosting]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.andrewhavens.com/?p=47</guid>
		<description><![CDATA[ Q: How do I set up PHP, Apache, MySQL, and Virtual Hosts on my Mac OS X 10.5?
A: That&#8217;s a good question! I&#8217;ve installed Apache, PHP, PEAR, Virtual Hosts, but haven&#8217;t had any luck with getting MySQL up and running. If you figure it out&#8230;please let me know!! Right now I&#8217;m using MAMP. Not [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2009%2F02%2F24%2Fhow-to-set-up-mac-os-x-105-for-web-development%2F&amp;t=How+to+set+up+Mac+OS+X+10.5+for+Web+Development&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p><strong>Q:</strong> How do I set up PHP, Apache, MySQL, and Virtual Hosts on my Mac OS X 10.5?</p>
<p><strong>A:</strong> That&#8217;s a good question! I&#8217;ve installed Apache, PHP, PEAR, Virtual Hosts, but haven&#8217;t had <em>any</em> luck with getting MySQL up and running. If you figure it out&#8230;please let me know!! Right now I&#8217;m using <a href="http://www.mamp.info">MAMP</a>. Not the ideal working environment, but it&#8217;s getting the job done for now.</p>
<p>This tutorial may be helpful in your journey of <a href="http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/">how to install MySQL on a Mac</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2009/02/24/how-to-set-up-mac-os-x-105-for-web-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to compare the differences between two arrays in PHP</title>
		<link>http://blog.andrewhavens.com/2008/10/30/how-to-compare-the-differences-between-two-arrays-in-php/</link>
		<comments>http://blog.andrewhavens.com/2008/10/30/how-to-compare-the-differences-between-two-arrays-in-php/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 19:21:40 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.amperactive.com/?p=27</guid>
		<description><![CDATA[ Question: How do I write a function to compare the differences between two arrays?
Consider the following scenarios:
$alreadyInTheDatabase = array('name' =&#62; 'Joe', 'address' =&#62; '123 Fake St');
$newFormValuesArray = array('name' =&#62; 'Joe', 'address' =&#62; 'My address has changed');

$alreadyInTheDatabase = array('name' =&#62; 'Joe', 'address' =&#62; '123 Fake St');
$newFormValuesArray = array('name' =&#62; 'Joe'); //a bad form has address [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2008%2F10%2F30%2Fhow-to-compare-the-differences-between-two-arrays-in-php%2F&amp;t=How+to+compare+the+differences+between+two+arrays+in+PHP&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p><strong>Question:</strong> How do I write a function to compare the differences between two arrays?</p>
<p>Consider the following scenarios:</p>
<pre class="brush: php;">$alreadyInTheDatabase = array('name' =&gt; 'Joe', 'address' =&gt; '123 Fake St');
$newFormValuesArray = array('name' =&gt; 'Joe', 'address' =&gt; 'My address has changed');

$alreadyInTheDatabase = array('name' =&gt; 'Joe', 'address' =&gt; '123 Fake St');
$newFormValuesArray = array('name' =&gt; 'Joe'); //a bad form has address missing from the array

$alreadyInTheDatabase = array('name' =&gt; 'Joe'); //address was never in the database to begin with
$newFormValuesArray = array('name' =&gt; 'Joe', 'address' =&gt; '123 Fake St');</pre>
<p>I&#8217;m writing a function to check whether or not I need to update a field in a database, so my function will tell me what the differences are between what&#8217;s already in the database, and what form fields have changed. If the field is the same as the one that&#8217;s in the database, I won&#8217;t need to update it. If the values are different, I&#8217;ll update. If the form has a field that doesn&#8217;t even exist yet in the database (because it hasn&#8217;t been created yet), I&#8217;ll need to know that too. So I&#8217;ll just return an array of the keys that differ.</p>
<p>There are a lot of PHP functions that exist to solve all sorts of scenarios where you would want to compare arrays, but none of them return an array of the differences between <em>both</em> arrays.</p>
<blockquote><p><a href="http://us3.php.net/manual/en/function.array-diff.php">array_diff</a> — Computes the difference of arrays<br />
<a href="http://us3.php.net/manual/en/function.array-udiff.php">array_udiff</a> — Computes the difference of arrays by using a callback function for data comparison<br />
<a href="http://us3.php.net/manual/en/function.array-diff-key.php">array_diff_key</a> — Computes the difference of arrays using keys for comparison<br />
<a href="http://us3.php.net/manual/en/function.array-diff-uassoc.php">array_diff_uassoc</a> — Computes the difference of arrays with additional index check which is performed by a user supplied callback function<br />
<a href="http://us3.php.net/manual/en/function.array-diff-ukey.php">array_diff_ukey</a> — Computes the difference of arrays using a callback function on the keys for comparison<br />
<a href="http://us3.php.net/manual/en/function.array-intersect.php">array_intersect</a> — Computes the intersection of arrays<br />
<a href="http://us3.php.net/manual/en/function.array-uintersect.php">array_uintersect</a> — Computes the intersection of arrays, compares data by a callback function<br />
<a href="http://us3.php.net/manual/en/function.array-intersect-assoc.php">array_intersect_assoc</a> — Computes the intersection of arrays with additional index check<br />
<a href="http://us3.php.net/manual/en/function.array-intersect-key.php">array_intersect_key</a> — Computes the intersection of arrays using keys for comparison<br />
<a href="http://us3.php.net/manual/en/function.array-intersect-uassoc.php">array_intersect_uassoc</a> — Computes the intersection of arrays with additional index check, compares indexes by a callback function<br />
<a href="http://us3.php.net/manual/en/function.array-intersect-ukey.php">array_intersect_ukey</a> — Computes the intersection of arrays using a callback function on the keys for comparison<br />
<a href="http://us3.php.net/manual/en/function.array-udiff-assoc.php">array_udiff_assoc</a> — Computes the difference of arrays with additional index check, compares data by a callback function<br />
<a href="http://us3.php.net/manual/en/function.array-udiff-uassoc.php">array_udiff_uassoc</a> — Computes the difference of arrays with additional index check, compares data and indexes by a callback function<br />
<a href="http://us3.php.net/manual/en/function.array-uintersect-assoc.php">array_uintersect_assoc</a> — Computes the intersection of arrays with additional index check, compares data by a callback function<br />
<a href="http://us3.php.net/manual/en/function.array-uintersect-uassoc.php">array_uintersect_uassoc</a> — Computes the intersection of arrays with additional index check, compares data and indexes by a callback functions</p></blockquote>
<p>Quite a lengthy list, isn&#8217;t it?? Now you can sense my confusion and frustration. We want to check the values, but return the key of the value that is different. We&#8217;ll also check the keys to see if we need to create a field that doesn&#8217;t already exist in the database.</p>
<p><strong>Answer:</strong> We&#8217;ll use array_diff_assoc() to return an associative array of the keys and values that differ in the first array. Then we&#8217;ll swap the arrays to check the second array against the first. We&#8217;ll merge the two arrays of differences using array_merge() and return just the keys by using array_keys().</p>
<pre class="brush: php;">function getDifferences($alreadyInTheDatabase, $newFormValuesArray) {

$diff1 = array_diff_assoc($alreadyInTheDatabase, $newFormValuesArray);
$diff2 = array_diff_assoc($newFormValuesArray, $alreadyInTheDatabase);

$merged = array_merge($diff1, $diff2);

$justTheKeys = array_keys($merged);

return $justTheKeys;

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2008/10/30/how-to-compare-the-differences-between-two-arrays-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a virtual host on a Mac running MAMP</title>
		<link>http://blog.andrewhavens.com/2008/10/23/setting-up-a-virtual-host-on-a-mac-running-mamp/</link>
		<comments>http://blog.andrewhavens.com/2008/10/23/setting-up-a-virtual-host-on-a-mac-running-mamp/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 08:32:20 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Virtual Hosting]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.amperactive.com/?p=3</guid>
		<description><![CDATA[ Update: I just found out about some great software that makes setting up virtual hosts with MAMP a breeze. You&#8217;d better check out this tutorial before reading mine, then go download VirtualHostX for only $9 dollars.
Or, if you want to do it for free, read on&#8230;
The super-easy, &#8220;How to set up name-based virtual hosts [...]]]></description>
			<content:encoded><![CDATA[<!-- Generated by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
	--><div style='float:right'><table > <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http%3A%2F%2Fblog.andrewhavens.com%2F2008%2F10%2F23%2Fsetting-up-a-virtual-host-on-a-mac-running-mamp%2F&amp;t=Setting+up+a+virtual+host+on+a+Mac+running+MAMP&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><p><strong>Update: </strong>I just found out about some great software that makes setting up virtual hosts with MAMP a breeze. You&#8217;d better check out <a href="http://seansperte.com/entry/Setting_Up_a_Killer_Local_Web_Development_Environment_on_a_Mac_with_MAMP_an/">this tutorial</a> before reading mine, then go download <a href="http://clickontyler.com/virtualhostx/">VirtualHostX</a> for only $9 dollars.</p>
<p>Or, if you want to do it for free, read on&#8230;</p>
<p><strong>The super-easy, &#8220;How to set up name-based virtual hosts on a Mac, running MAMP&#8221;, Tutorial</strong></p>
<p>When I&#8217;m developing a new website for a client, I like being able to open my browser and test out the site I&#8217;m working on. So lately I&#8217;ve been uploading my &#8220;work in progress&#8221; to a new sub-domain that only I know, such as http://stage.myClient.com or http://alpha.myClient.com. The problem with this approach is that even though I&#8217;m the only one who &#8220;knows&#8221; what the address is, people can still find, and view my unfinished business since it&#8217;s publically accessable. What I really want to do is test my site, in my browser, just as if it was on the web, without anyone being able to see it, but me.</p>
<p>There&#8217;s a really easy way to do this. It&#8217;s called <a title="Virtual Hosting" href="http://en.wikipedia.org/wiki/Virtual_host">Virtual Hosting</a>. Name-based virtual hosting will allow us to associate http://stage.myClient.com with a directory on our computer, rather than going out to the internet. The great thing about this is that we can name our virtual host whatever we want. We could call it http://stage.myClient.com or http://local.myClients.clientOne. We could even name it http://foobar if we felt so inclined. http://localhost is an example of a virtual host. Go ahead and type that into your address bar. I&#8217;m not sure what you&#8217;ll get back, but it&#8217;s probably already set up and redirecting to a folder on your computer somewhere.</p>
<p>If you&#8217;ve already downloaded and installed <a title="MAMP" href="http://www.mamp.info/en/mamp.html">MAMP</a>, good for you! If you haven&#8217;t, you really should. If you&#8217;re developing websites in <a title="PHP" href="http://php.net">PHP</a>, and you want to test your site without having to upload it to your server, you need to install PHP on your computer. The same goes with using a <a title="database" href="http://www.mysql.com/">database</a>. Setting these up individually can be a pain! MAMP is nice because it installs everything you need, you can turn it on and off, and it makes it really easy to start developing websites locally without having to set anything up. This tutorial is about setting up a virtual host, on a Mac, running MAMP, so I&#8217;m going to assume you&#8217;ve already got MAMP set up.</p>
<p>So one of the things you might have noticed about MAMP is that it sets its &#8220;localhost&#8221; directory to /Applications/MAMP/htdocs&#8230;which is fine, except I like to keep my sites in my /Users/andrew/Sites directory. I mean&#8230;that&#8217;s what it&#8217;s there for.</p>
<p style="text-align: center;"><a href="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-21.png"><img class="size-full wp-image-14 aligncenter" title="screenshot of a Mac users' home directory" src="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-21.png" alt="" width="334" height="121" /></a></p>
<p>So if you want to set yours up that way&#8230;</p>
<ol>
<li>Start MAMP.</li>
<li>Click &#8220;Preferences&#8230;&#8221;</li>
<li>Click the &#8220;Apache&#8221; tab</li>
<li>Browse to the directory of your choice</li>
</ol>
<p>Now going to http://localhost should resolve to the directory that you chose. Now, let&#8217;s set up our very own virtual host!</p>
<ol>
<li>Open Terminal by going to /Applications/Utilities/Terminal</li>
<li>Type: sudo pico /etc/hosts</li>
<li>Type your Administrator password<a href="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-31.png"><img class="aligncenter size-full wp-image-13" title="Editing /etc/hosts in Pico" src="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-31.png" alt="" width="381" height="243" /></a></li>
<li>Edit your hosts file to look like mine, with exception to your chosen virtual host name. I&#8217;ve named my virtual host stage.myClient.com</li>
<li>Press Control+O, then Return to save the changes</li>
<li>Press Control+X to exit Pico</li>
</ol>
<p>One last step:</p>
<ol>
<li>Open /Applications/MAMP/conf/apache/httpd.conf (TextEdit is fine)</li>
<li>Scroll to the very bottom, this is where we declare our virtual host.<a href="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-4.png"><img class="aligncenter size-full wp-image-9" title="httpd.conf screenshot" src="http://blog.andrewhavens.com/wp-content/uploads/2008/10/picture-4.png" alt="" width="384" height="260" /></a></li>
<li>Edit your httpd.conf file to look like mine. The server name should be the name of your virtual host that you declared in the previous file, and your document root should be the directory you want your virtual host to pointing to.</li>
</ol>
<p>We&#8217;re done! Make sure you have MAMP running when you try it out for yourself.</p>
<p>If you found this tutorial helpful, or if you want to tell me how <span style="text-decoration: line-through;">much it sucks</span> to make it even better, please leave a comment!</p>
<p>Thanks, for reading!</p>
<p>&#8211;Andrew</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhavens.com/2008/10/23/setting-up-a-virtual-host-on-a-mac-running-mamp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
