* By “The Right Way”, I mean following the guidance and practices at the PHP: the Right Way website. I make no claims this is the “best” way 🙂

Works n my machine badgeMac OS X is a pretty good web developer OS. It comes as standard with PHP, Ruby and Apache all out of the box, and the underlying UNIX system makes it easy to add in other languages and components to suit your needs. On top of that, some of my favourite development tools are on the Mac, so unless I’m writing .NET code, nearly all my development is on an (ageing) Mac Mini.

Now, while all that stuff comes as standard on OS X, lately it seems Apple has made it harder to get to. The versions shipped with OS X also tend to be a little behind the latest releases. As a result, most Devs I know use something like MAMP to make the server-side of their environment as easy as running an app. Personally, while I think MAMP works, and is a good time-saver (and I’ve been using it for the last year or so), but I like to get into the nitty-gritty of the system and get things running “native”. So last night I fired up the terminal and got PHP set up on my Mac with the latest version, and following the Right Way Guidelines. As a result I have PHP 5.4, Composer, the PHP Coding Standards Fixer, and MySQL all setup quite slickly (i.e. to my preferences).

The whole process was pretty easy, but does involve the command line. If this makes you uncomfortable, then it might be best to skip the rest of this post.

This all worked on my Mac, but I make no guarantees about it working on yours, and I’m not responsible if you break something.

If you find any glaring problems with this guide then leave a comment/get in touch, and I’ll make any required edits.

Step 1: Setup Your PATH

Edit the hidden .bash_profile file in your home directory. If you use Sublime Text 2 you can use the following command:

subl ~/.bash_profile

TextMate has a similar mate command, or you can use vi(m)/nano/emacs/whatever.

It’s possible you already have a line defining your PATH variable. It’ll look something like export PATH=<something>. I’ve found it most useful to change the PATH so /usr/local/bin is at the start, making sure anything you install there is used over the system defaults in /bin. Add this as a line below your existing PATH definition (or just add it in, if you don’t have an existing line):

export PATH=/usr/local/bin:${PATH}

Step 2: Install Brew

Strictly speaking, Brew (aka Homebrew) isn’t required, but I used it to install MySQL later, and it does make it stupid easy to install stuff into OS X. I think you should install it. The best instructions are found on the Homebrew home page, so go have a read there. There are a few pre-requisites, but nothing too difficult.

Step 3: Install PHP-OSX

Now we’re beginning to get somewhere! PHP-OSX is the latest versions of PHP compiled for OSX by Liip. Installation is a real doddle, from the command line:

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4

Follow the prompts given, including entering your password. After a few moments everything will have installed. For convenience I created a symbolic link to the newly installed PHP binary in /usr/local/bin:

ln -s /usr/local/php5/bin/php /usr/local/bin/php

Step 4: Install Composer

Now we have PHP installed, it’s time to look at the nice-to-haves, like a good package/dependency manager. Composer is relatively new on the block, and allows others to download your code and automatically grab any dependencies by running a simple command.

You can install Composer in your project, or you can install it globally. I prefer globally. As with PHP, installation is simple, from the command line:

curl -s http://getcomposer.org/composer.phar -o /usr/local/bin/composer
chmod +x /usr/local/bin/composer

Step 5: Install PHP Coding Standards Fixer

Another nice-to-have, this little tool will try to find and fix parts of your code where it does not conform to one of the PHP Coding Style Guides. Installation is almost identical to Composer:

curl http://cs.sensiolabs.org/get/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer
chmod +x /usr/local/bin/php-cs-fixer

Step 6: Install MySQL

If you installed Brew in step 2, then you’re good to go with this little command:

brew install mysql

It’ll take a few minutes, but you shouldn’t need to intervene at all. Once done you will need to run two more command to setup the MySQL tables:

unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

If you didn’t install Brew, then you will need to install MySQL through some other means, such as packages on the MySQL website. I can’t help you with that, I’m afraid.

For managing MySQL, I use the excellent Sequel Pro, which is a successor to the venerable CocoaSQL.

As a next step you should look into changing the root password of your MySQL setup. This is a local dev environment, and likely only used locally by yourself, but it’s the proper thing to do.

Errata

  • Pear doesn’t seem to work, which is slightly annoying, but (to me) no real biggie. I didn’t test this with the built-in version of PHP, so I don’t know whether it worked beforehand. I’ll post an update once I figure it out.
  • I’d like to make bash script smart enough to stop MySQL when the PHP web server stops, but my early attempts haven’t managed to get this working (most likely due to the Ctrl-C used to stop the web server also stopping the script).
  • Throughout this process we’re running scripts directly from the web. This is pretty risky behaviour, especially with unknown/untrusted sources. You should always take a look at the raw script before running it, so you don’t get hit by something malicious.

So a Windows version of Safari is finally here. Hurrah, another browser to support. Cynicism aside, is it any good?

Now, bearing in mind this is a beta version, there are a few issues I have. These are only my personal annoyances, based on first impressions, and in no way a comprehansive list of bugs.

It’s Fugly.

Fugly in the sense of it dowsn’t fit in with the surrounding OS one little bit. Not even an iota. I give Apple credit for porting the thing in the first place, and I know there’s a kind of UI “branding” to stick to, but the window border looks awful.

Another issue is the font rendering. I have Windows ClearType turned on for font smoothing. Safari has its own font smoothing (which can’t be turned off – another annoyance). The combination of two font smoothing algorythmns makes text look almost bold. It needs sorted ASAP.

There’s the Aqua-style widgets as well, but there a minor annoyance.

It’s Inconsistent

I can middle-click on a link in a web page, and it opens in a new tab. If I middle-click on a bookmark, it does nothing. That irritates me no end. Off the top of my head, some dialogs open in OSX-style “slide-down” windows, others don’t. Maybe this is a OS limitation? Or am I imagining it?

No dotMac Sync

I know, I know… dotMac sucks. But it has one very useful feature which I use extensively – bookmark syncing. I had hoped the Windows version of Safari would include this, but alas, it’s not there. Maybe they’ll add it in before the final version? If not, I don’t know if Safari will be able to compete against Firefox + Google Browser Sync as my first-choice of browser. I’m giving it the benefit of the doubt for the moment, simply for the speed boost over Firefox, but speed alone won’t keep it in front.

So all round, Safari on Windows is a bit meh, hovering precariously close to pure dissapointment. For now, I’m willing to the give Apple the benefit for the doubt – it is a beta version, after all.

As one final note, how to do you bring up the web inspector panel I’ve heard so much about? Email chris@ this site with the answer, please!

Something I like to do for each of my Macs, is keep a backed-up folder containing all the “essential” apps for both machines (along with all registration codes for easy reinstallation). I was updating my iBook copy this evening and thought I’d share. Some of these are generic apps that I’d use on either machine, while others are iBook specific.

Side-note – My iBook is pretty exclusively a web development machine.

Textmate. Textmate describes itself as “the missing editor for OS X”. I’m not sure what that’s meant to mean but hey, I’ll take their word for it! Textmate was the first Mac App I ever bought and is by far the best file editor I have ever used. Textmate handles just about any text file format you can throw at it, and above all else, lets you work without getting in your way. Seriously worth trying.

Ecto. Ecto is the best blogging client in the world. Especially on the Mac. I used to be a fan of MarsEdit (I own licenses for both), but Ecto won out in the end for its wider range of features. If you’re in any way serious about this blogging malarkey, I’d recommend you give it a try. Even the Windows version is recommended (although, naturally, it’s nowhere near as good as the Mac edition!)

Transmit. If Textmate was the first Mac App I paid for, then Panic Software’s Transmit was the second. It’s a S/FTP client with more features than you’re ever likely to need, but wrapped in a highly polished and intuitive interface. Transmit makes working with files on remote servers as effortless as working with local files in Finder. The synchronisation features alone are worth the price of the license.

Coconut Battery. More of a useful widget than an application, Coconut Battery can tell you near enough anything you need to know about the status and health of your battery. Ideal for checking if you want to know if you’ll be needing to buy a replacement any time soon.

Colloquy. Sometimes, the best – or only – way to get help on open-source applications/scripts, etc, is to jump into an IRC room. Colloquy is the best OS X IRC client I’ve found. As a rule, I don’t like chat or IM applications (they tend to be little more than a distraction), but Colloquy has helped me get access to the right answers on more than one occasion.

That’s really it for my iBook’s list of essential apps; I try to keep laptops “light”, hence the short list. My iMac list is probably huge in comparison. Besides, my other needs are either met by the apps bundled with OS X – Safari for web browsing, Terminal.app for command-line activity (remote sessions, etc.), iTunes and what-not, or by web applications –PHPMyAdmin for MySQL administration, Roundcube for accessing my IMAP email anywhere. Are there any applications you can’t live without on your Apple laptop? Please share!

I’ve had my iBook for about 48 hours now, and I’m beginning to find my way. OS X (or is it OSX?) is a completely new experience to me, but I think I’m taking to it rather well. I’m still getting used to the difference between shutting an application and quitting an application, but that’ll come in time! For what it’s worth, I wanted to jot down my initial experiences and reactions with the switch. I won’t go into too much detail just yet – I’ll save that for later articles.

  • File browsing is more intuitive, especially after I switched to column view in Finder.
  • A lot more emphasis is placed on using keyboard commands than in Windows…
  • …Which is just as well, as the trackpad is a bit pants.
  • Software installation is a breeze. It’s so simple and logical. Drop the application into the applications folder and away you go!
  • I’m still not sold on the Dock, but I haven’t done any tweaking yet (other than the size of it)
  • Everything just looks better. From the icons to the text to the GUI widgets… it’s just better!

So far, I haven’t done anything to set up the machine for local development/testing. I plan to do this later this week, after I’ve done a bit more reading – I want to set up SVN and Ruby/Rails, both of which I’ve never set up before (or even used before, in the case of Ruby/Rails!). Another thing that I haven’t done yet, is transferred any old files onto the iBook. That’s tonight’s job.