Creating a CakePHP environment using MAMP and OS X

This will show you how to create a CakePHP environment in MAMP on OS X. Here list of softwares used and their version.

  • OS X Leopard or Snow Leopard
  • MAMP version 1.91 (using PHP5.2.x)
  • CakePHP 1.2.8

You shouldn’t have to use MAMP 1.9.1. I have it working on version 1.8.x. You will need to change Apache’s port from 8888 to 80. Make sure there aren’t any other web servers running on the same port. Leave MySQL running on port 8889. We will be creating a /Applications/MAMP/conf/apache/sites file that will store your virtual sites. It isn’t necessary but it’s easier to manage new sites on a separate file. You will need to edit the /Applications/MAMP/conf/apache/httpd.conf file by adding the following lines of code.

# virtual hosts file
Include /Applications/MAMP/conf/apache/sites

This will tell Apache to check the new sites file for additional configurations. So now, whenever you need to add or create a new site, you will edit the sites file and add the following code.

<VirtualHost *:80>
DocumentRoot /Users/username/Sites/projectname
ServerName projectname.local
</VirtualHost>

The value of DocumentRoot can be different. I just chose to put it in that folder. Now you will need to edit your /etc/hosts file by adding the following code.

127.0.0.1          projectname.local

Restart your MAMP server. Now unzip the CakePHP files into the projectname folder. You should now be able to view your new CakePHP site by directing your browser to http://projectname.local. This page will tell you that you need to change the default Security.Salt value. All you need to do is change at least one character and you will meet the requirement. You can also use Terminal to generate your own.

echo -n ‘foobar’ | openssl sha1

This will give you a 40 character string. You can use a mixture of upper and lower case on the letters. Copy and paste this value from Terminal to give a new Security.Salt value.

The next warning is your database. Rename the database file and edit it. Provide your database server information. Because MySQL in MAMP is using port 8889, you will have to edit the array and add the following.

‘port’ => ’8889′

There are notes in this file to help you further with additional array elements.

To use Terminal with the cake command, you will have to edit you ~/.bash_login file and create aliases. Here is the code to add to your .bash_login file.

# php
alias php5=”/Applications/MAMP/bin/php5.2/bin/php”

# cake for this project
alias cake=”php5 /Users/username/Sites/projectname/cake/console/cake.php”

To apply

. ~/.bash_login

You should be able to run

cake help

If you get a permission denied error, give it executable access with this.

chmod +x /Applications/MAMP/bin/php5.2/bin/php

That’s it. You can now start baking in a development environment. I know I have skipped a few steps but I’m assuming you know the basic commands and configurations. If not, please feel free to comment and ask questions. I’m still new with the MVC framework and CakePHP so go easy on questions regarding those. I am learning, slowly… haha!

Snow Leopard upgrade surprise

My work recently ordered our Snow Leopard DVD so we can upgrade our iMacs. I did my usual Time Machine backup and upgraded. I didn’t worry much about compatibility since my personal 13″ MBP has been running SL for a few months now and it had the same apps installed – no problems at all.

After I upgrade my work’s iMac, there were problems. I kept getting errors from my Symantec antivirus (I had to install it, work policy even though it isn’t necessary). I reinstalled it and it warned me to install Rosetta. I thought that would be the “aha” so I installed it. It looks like it fixed that problem, but now my Adobe CS3 apps crashes when I launch them. I Googled and it turns out there is an existing compatibility issue with CS3 and SL. It’s weird though since my MBP runs CS3 without a problem.

So now I got another external firewire hard drive. What I’m going to do is restore a backup that I made in Time Machine before upgrade onto an external hard drive. This way I can make sure that’s a clean copy before formatting and restoring it onto my iMac’s hard drive. This is why I love using Macs. When running into problems, I have several options to restore without losing data – as long as you back up data.

Once this is complete and I’m satisfied with the restored data, I will restore the backup onto the iMac. Then I’ll format the external drive and install a clean copy of SL and migrate my Leopard over to see if it’s SL or just my iMac configurations.

Snow Leopard UTD finally arrived

After 6 days since the release of Snow Leopard, my UTD discs finally came in the mail yesterday. I was somewhat upset during launch day when my order status said backordered. It’s puzzling that the company who made the software and distributes it, is backordered. I could’ve gone to the store and bought a full version. I heard they had a ton there.

My co-worker got his full version copy 10am that day. I couldn’t wait so I borrowed it from him after he upgraded his MBP and upgraded my MBP. So far I’ve gotten a few app crashes but it seems after the first crash, they tend to run normal again. I hear 10.6.1 is around the corner so it should fix some stuff.

Anyways, here are some pics I took.

As you can see from the 3rd pic, the UTD (Up to date) discs are upgrade only. The retail $30 ones should be full versions. Another thing I noticed is there is a Optional Install folder now on the disc. It has OS X applications such as Mail, iCal, Address Book, etc. Also has Rosetta. This is great coz in the past, if any of the apps needs to be reinstalled, you can either copy it from another working OS X and fix the permissions or reinstall OS X. Now just pop in the Snow Leopard disc and you can install it anytime.

Here’s a before and after pic of my hard drive on my Mac Mini MB138LL/A. Notice the changes to the hard drive size.

Here’s an article that explains about the capacity change – http://blogs.zdnet.com/storage/?p=589.