November 2007 Archives

OS X Leopard local web development with Apache and PHP5

Posted on November 20th, 2007 by Jeff

My previous posting regarding local web development on Mac OS X was geared towards those running OS X Tiger and Apache 1.3. The new Mac OS X Leopard comes with the 2.2 version of Apache, and with it some tweaks to the way things are set up.

PHP comes pre-installed, giving Marc Liyanage a lot more free time and making your life much nicer. First thing to do is to activate PHP5 by opening up the httpd.conf file.


sudo vi /etc/apache2/httpd.conf

To include PHP5, simply uncomment the following line:


# LoadModule php5_module libexec/apache2/libphp5.so

In order to develop multiple sites locally, use virtual hosts. I had trouble using the default httpd-vhosts.conf file, so I added my own sites.conf file. Add this line to the bottom of your httpd.conf file:


Include /etc/apache2/other/sites.conf

Next, create the actual conf file you just referred to.


vi /etc/apache2/other/sites.conf

Create a new virtual host for MySite by adding a record to the sites.conf file


# Enable named virtual hosts
NameVirtualHost *:80
# Override the default httpd.conf directives.  Make sure to
# use 'Allow from all' to prevent 403 Forbidden message.

	Options ExecCGI FollowSymLinks
	AllowOverride all
	Allow from all

# A basic virtual host config

	ServerName yoursite
	DocumentRoot /Users/username/Sites/yoursite

Edit the hosts file…


sudo vi /etc/hosts

… and add a line with your new site


127.0.0.1       yoursite

You should create a folder called “yoursite” in the default Sites folder. At this point you will need to restart Apache to pick up the changes.


sudo apachectl restart

You should now be able to view your site locally at http://yoursite/. In order to maintain multiple virtual hosts, simply add another record to your sites.conf file.



	ServerName yoursite2
	DocumentRoot /Users/username/Sites/yoursite2

and add the corresponding record to the /etc/hosts file.


127.0.0.1       yoursite2
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

DataMapper 0.2 and Rails

Posted on November 17th, 2007 by Chris

The DataMapper ORM framework is forging ahead and is now on version 0.2.3. In my previous DataMapper post I wrote about how to get started using the 0.1 release of DataMapper in Rails. Today, let’s look at some of what’s new installation-wise, as well as how well DataMapper is handling relationships between our model objects.

First of all, the DataMapper crew has changed to using DataObjects.rb for its database driver stuff. If you’re running OSX Leopard and MySQL as we are here at Bust Out, then you’ll want to visit this excellent post to help you get up and running.

Two addendums to the above. The first is that I needed to install the json_pure gem as well in order to get DataMapper running correctly:


    sudo gem install json_pure
 

Secondly, if you happen to encounter something like this little gem when firing up your Rails console:


dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.
15.dylib
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/
mysql.bundle
Reason: image not found
Trace/BPT trap

you can fix it using the following suggestion from the DataMapper mailing list.

Now that we hopefully have our new version of DataMapper correctly installed, lets take a look at it in action. Last time around, I made myself a drink to celebrate the successful install of DataMapper. This time, let’s continue building our restaurant by including a bar and then invite some people over to discuss the relative merits of ORM design patterns (or not):


>> r = Restaurant.new
=> #
>> r.name = “Hawaiian BBQ”
=> “Hawaiian BBQ”
>> r.save
=> true
>> b = Bar.new
=> #
>> b.name = ‘Hula Lounge’
=> “Hula Lounge”
>> b.restaurant = r
=> #
>> b.save
=> true
>> b.restaurant
=> #
>> p = Patron.new
=> #
>> p.first_name = “jeff”
=> “jeff”
>> p.last_name = “lin”
=> “lin”
>> p.save
=> true
>> r.patrons << p
=> [#]
>> r.save
=> nil
>> r.patrons
=> [#]
>> p = Patron.find 1
=> #
>> p.restaurant
=> #
>> d = Drink.new
=> #
>> d.name = “Trumer Pils”
=> “Trumer Pils”
>> b.drinks << d
=> [#]
>> b.save

Hopefully at this point you get the idea that associations are working quite nicely in DataMapper (assuming any of the above is remotely helpful…wasn’t the most fun to type). So, rather than show you the model classes and keep typing along in the console, I suggest that DataMapper users read the specs that are bundled with the source. They’re quite informative and a good example of how to write specs as well.
Be sure to check out the DataMapper site as well and look for ways to contribute.
Cheers!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Play is the new work

Posted on November 11th, 2007 by Jeff

Play

Bust Out Solutions has had the pleasure of maintaining a strong partnership with Play, one of the top branding and design boutiques in the Twin Cities. We recently launched their newly self-designed website, powered by a dynamically generated portfolio and an integrated content management system for easy updates. Check it out and try not to drool too much over the pretty pictures.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]