Web Page Templates Icons, Clipart, Logos

Blog

Hot Topics

Post Archive

Tags

Aug 04, 2009 12:48 AM EDT

Rails Select Helper

Ruby on Rails has a bunch of built in tools to make it easy to create HTML form elements. In fact, there are so many different ones that it’s sometimes confusing to know which one to use.

Here is an example of how to build a static drop down box with the display text and the value:

Select helper:
<%= select( "controller-name", "column", { "Tools" => "T", "Reference Resources" => "Resources"}) %>

Replace controller-name with the Rails controller that you’re going to use, “column” would be the database column where you plan to store the data, and the info between the {} is the options list. For example, { “Tools” => “T” } creates: <option value=”T”>Tools</option>

Of course, you can pass in a collection or array that was generated from a database query so that the option list is dynamic.

Darren ruby on rails | helper
Aug 04, 2009 12:46 AM EDT

Upgrading Invision Powerboard 1.2 and 1.3 to use PHP5 and MySQL5

Invision Powerboard 1.2 and 1.3 are still used by many people because they’re free, where the newest versions are not. However, the coding for them isn’t 100% compatible with the latest versions of PHP and MySQL. Many web hosting companies are moving to PHP5 and MySQL5, and this will break the default installation of IPB. Here is a collection of the changes you’ll need to make to your files so that IPB 1.2 or 1.3 will work with PHP5 & MySQL 4.1 or greater.

If your forum is experiencing any of these issues, the rest of this article may fix your problem. Make sure you back up your files and database before making any changes, just in case.

Symptoms:

Blank ‘Profile’ page
Blank ‘My Controls’ page
MySQL errors when reporting post
MySQL errors on ‘The Moderating Team’ page

Files affected:

sources/misc/contact_member.php
sources/Profile.php
sources/Usercp.php
sources/misc/stats.php

Step 1:
Open sources/Usercp.php

Find:

var $parser;

Change To:

//var $parser;

Save and upload sources/Usercp.php

Step 2:
Open sources/Profile.php

Find:
var $parser;

Change To:
//var $parser;

Save and upload sources/Profile.php

Step 3:
Open sources/misc/contact_member.php
Find:

var $email = “”;
var $forum = “”;
var $email = “”;

Change To:

//var $email = “”;
var $forum = “”;
var $email = “”;

Find:

$DB->query(”SELECT m.name, m.email, mod.member_id FROM gallerymoderators mod, gallerymembers m WHERE mod.forum_id=’$fid’ and mod.member_id=m.id”);

Change To:

$DB->query(”SELECT m.name, m.email, moder.member_id FROM gallerymoderators moder, gallerymembers m WHERE moder.forum_id=’$fid’ and moder.member_id=m.id”);

Save and upload sources/misc/contact_member.php

Step 4:
Open sources/misc/stats.php
Find:

//——————————————–
// Do we have any moderators? NORMAL MODS 1st
//——————————————–

$DB->query(”SELECT m2.id, m2.name, m2.email, m2.hide_email, m2.location, m2.aim_name, m2.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators mod
LEFT JOIN galleryforums f ON(f.id=mod.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m2 ON (mod.member_id=m2.id)
“);

Change To:

//——————————————–
// Do we have any moderators? NORMAL MODS 1st
//——————————————–

$DB->query(”SELECT m2.id, m2.name, m2.email, m2.hide_email, m2.location, m2.aim_name, m2.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators moder
LEFT JOIN galleryforums f ON(f.id=moder.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m2 ON (moder.member_id=m2.id)
“);

Find: (this edit isn’t in 1.2, so you should be able to skip this step if that’s your version)

//——————————————–
// Do we have any moderators? GROUP MODS 1st
//——————————————–

$DB->query(”SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators mod
LEFT JOIN galleryforums f ON(f.id=mod.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m ON ((mod.is_group=1 and mod.group_id=m.mgroup))
“);

Change To:

//——————————————–
// Do we have any moderators? GROUP MODS 1st
//——————————————–

$DB->query(”SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators moder
LEFT JOIN galleryforums f ON(f.id=moder.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m ON ((moder.is_group=1 and moder.group_id=m.mgroup))
“);

Save and upload sources/misc/stats.php

Step 5:
Add the following code to the top of index.php and admin.php:

//– mod_php5 begin
$HTTP_SERVER_VARS = isset($_SERVER)?$_SERVER:array();
$HTTP_GET_VARS = isset($_GET)?$_GET:array();
$HTTP_POST_VARS = isset($_POST)?$_POST:array();
$HTTP_POST_FILES = isset($_FILES)?$_FILES:array();
$HTTP_COOKIE_VARS = isset($_COOKIE)?$_COOKIE:array();
$HTTP_ENV_VARS = isset($_ENV)?$_ENV:array();
$HTTP_SESSION_VARS = isset($_SESSION)?$_SESSION:array();
//– mod_php5 end

———

Portions of this article was paraphrased from a post by FuSoYa at http://forums.invisionize.com/index.php?showtopic=73882

Darren invision powerboard | php | mysql | database | compatibility
Aug 04, 2009 12:41 AM EDT

Install/Upgrade to Rails 2.0.2 with Eclipse, Aptana RadRails, and Subclipse

If you’re getting started with Ruby on Rails, one of the better platforms to program in is Eclipse largely due to RadRails and the SVN plugin called Subclipse. Eclipse and the community versions of the plugins are free, so it’s definitely worth taking a look at.

This article is assuming that you have a working (but possibly outdated) version of Rails installed.
If not, and you’re running on Windows, I recommend searching for the InstantRails package and installing that first.
If you’re running Mac or Linux, you’ll need to install/upgrade Ruby to the latest version and then you can proceed with the following gem commands.

To Upgrade Rails:
gem update –system
gem update
gem update rails
gem cleanup

If you run into errors (possibly when you try and add your first rails project) try:
gem uninstall rails
gem install rails
gem cleanup

Eclipse:

Go to www.eclipse.org and find the latest version to download. The page is currently at:
http://download.eclipse.org/eclipse/downloads/drops/R-3.3.1.1-200710231652/index.php

Download the “Platform Runtime Binary (About 40mb)” for your Operating System.
Unzip this folder to whereever you want the install files of Eclipse to be.
Open the folder and find the Eclipse executable, and make a shortcut of it.
Move this shortcut into your start menu, desktop, or whatever you use to get to your programs.

Aptana Plugin:

Go to: www.aptana.com
Click on “get it now” for the community edition.
scroll to the bottom of the page and click “download” for the community edition.
click on the eclipse plugin tab
Click on download

In Eclipse: click on help, software updates, find and install.
Search for new features to install.
Click next
Click “new remote site”
Name it “Aptana”
Enter in the URL (which at the time of this writing is:
http://update.aptana.com/update/3.2/)
Follow the prompts, and select to download “Aptana” when it asks for it.

Subversion Plugin (called Subclipse):

http://subclipse.tigris.org/
Click on help, software updates, find and install.
Search for new features to install
Click next, then “new remote site”
Name it “Subclipse”
Enter in the URL found on the Subclipse website. Currently it is:
http://subclipse.tigris.org/update_1.2.x

Follow the prompts, but uncheck the integration box because you don’t have those plugins installed.

Click Install All and Restart Eclipse when it asks you.

Aptana Rad Rails:

Open Eclipse
On the Aptana Home Page (must have Aptana installed first), at the bottom of the Languages section, there’s a link to install Aptana RadRails.
Uncheck the Ruby Mylyn Connector Feature.
Follow the prompts, install all, reboot Eclipse when it asks you.

Show SVN Repository:

In Eclipse, click on Window, Show View, Other.
Open up, SVN folder, click on SVN Repository, Click OK.

Add Rails and Rake Paths to Eclipse:

Click window, preferences, click on plus sign next to Rails, click on Configuration. Browse to your rails files.
On my Windows computer, (using the Instant Rails package), the paths were at:

C:\InstantRails\InstantRails\ruby\bin\rails
C:\InstantRails\InstantRails\ruby\bin\rake
C:\InstantRails\InstantRails\ruby\bin\mongrel_rails

Of course, this totally depends on where you installed Ruby.

Click Apply to save them.

Other Eclipse Configuration Options:

Click window, preferences.
Click on Team, SVN
Check “Select unversioned resources on commit”
Click on Apply.

In the preferences window, click on “Team”, “Ignored Resources”, Add Pattern.
Add “.project” and “.log”. If your computer saves that annoying Thumbs.db file, you might want to ignore that one too.

Good luck, and I hope this was useful to you.

Darren ruby on rails | install | eclipse | aptana radrails | subclipse
Aug 04, 2009 12:36 AM EDT

Using scp and rsync instead of ftp to copy files on Linux

If you want to copy files to another computer, it’s more secure to use scp (secure copy) than ftp.

Using SCP:
scp -pr * username@example.net:destination_path

In the command, -p stands for “preserve”, in other words, it keeps the last modified time, access time, etc the same, and -r recursively copies subdirectories.

Using Rsync:
If you want to just copy files that have changed, a better solution is to use Rsync:

rsync -ra –progress –verbose –delete –rsh=/usr/bin/ssh –size-only * username@example.net:destination_path

-r in this command is for recursive copies, and -a stands for archive, which keeps the modified times the same. –progress and –verbose outputs everything it’s doing and lets you know how much more it needs to check, –delete deletes anything that doesn’t exist at the source location any longer, –rsh makes sure you’re using ssh for security reasons, –size-only updates anything where the filesize has changed. Normally, it compares hashes of the files but that takes more time to process. The * is the source location, which would normally be a path somewhere if it’s in a cronjob, and the last part is the destination location, which doesn’t need a trailing slash; for example, public_html/images

To automate Rsync, you’ll need to have ssh keys installed so that you can bypass the need to enter in a password.

Installing an ssh key:

Run this command on the source computer:

ssh-keygen -t dsa

This will create a pair of keys at $home_dir/.ssh/ and by default, the public key will be called id_dsa.pub

Security Note: When you create your key, it will ask for a password. If you leave it blank, you’ll be able to ssh to the destination box without needing a password, which is useful when you need ssh in an automated script; however, this makes it less secure in the case where somebody compromises your user account - they would then have access to all of the machines with your public key installed. However, if you use a password, you’ll need to enter that password each time you want to ssh, which will be problematic in automated scripts.

Copy the contents of the public key to the destination computer at:

$home_dir/.ssh/authorized_keys

Troubleshooting:

Occasionally, I’ve gotten this error, which prevented me from copying files inside a particular directory, and it confused me at first because my user had read permissions, but it wouldn’t copy until I gave the directory execute permissions too:

rsync: recv_generator: failed to stat “/path/to/file”: Permission denied (13)

The way I got around this was to run: ‘chmod 777 thefile’, but ‘chmod 700 thefile’ should work too assuming that you don’t want anybody seeing the file but you. A 7 in that command sets it to rwx or read, write, and execute.

SCP is great for copying the contents of a folder, while Rsync is great to mirror or back up files, and with a combination of the two, you’ll rarely need to use FTP again.

Darren scp | file copy
Aug 04, 2009 12:30 AM EDT

X-cart 4.1 multiple monthly payments module

This is more of a set of modifications rather than an actual module, but the end result is the same.

First thing you’ll need to do is backup your existing site and database. I’d recommend using a test install of Xcart so that nothing in production gets messed up. With that in mind, the first step is to alter the pricing table by using the following alter table command. If you have a different version of MySQL, you might need to tweak this a bit.

ALTER TABLE `xcart_pricing` ADD COLUMN `numpymnts` INTEGER UNSIGNED NOT NULL DEFAULT 1,
ADD COLUMN `paymentprice` DECIMAL(12,2) NOT NULL DEFAULT 0 AFTER `numpymnts`,
ADD COLUMN `sourceproductcode` VARCHAR(255) DEFAULT 0 AFTER `paymentprice`,
ADD COLUMN `sortby` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `sourceproductcode`,
ADD COLUMN `mastervariant` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `sortby`,
ADD COLUMN `price_override` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `mastervariant`,
ADD INDEX `numpymnts`(`numpymnts`),
ADD INDEX `paymentprice`(`paymentprice`),
ADD INDEX `sortby`(`sortby`),
ADD INDEX `sourceproductcode`(`sourceproductcode`),
ADD INDEX `mastervariant`(`mastervariant`),
ADD INDEX `price_override`(`price_override`)
, ENGINE = MyISAM;

The new columns are as follows:
numpyments = number of payments
paymentprice = price the export expects to see (might be one payment or the total)
sourceproductcode = product code (sku) that export expects to see
sortby = the order in which the variants show up on the admin page
mastervariant = overrides the ’starting at’ price
price_override = use this table for the price instead of the orders table for reporting

Next, you’ll need to modify some of the admin template files, such as:

Modify Files:
/skin1/modules/Product_Options/product_variants.tpl - add fields to the variants html table - don’t add the price_override column.

/modules/Product_Options/func.php - edit func_get_product_variants and add in the columns that were added to the product_variants.tpl file

When you submit the variants, the form goes to:

product_modify.php
section=variants
mode = product_variants_modify
productid = [variable]
submode = “data”
geid = “”

Once sumbitted, the code is run in this ELSEIF block in modules/Product_Options/product_variants.php:
} elseif ($mode == ‘product_variants_modify’ && $vs && $submode != ‘prices’) {

In here, you need to edit the $query_price_data array to include the additional fields; for example:

## BB Edit - added additional fields
$query_price_data = array(
"price" => $v['price'],
"variantid" => $k,
"productid" => $productid,
"quantity" => 1,
"membershipid" => 0,
"numpymnts" => $v['numpymnts'],
"paymentprice" => $v['paymentprice'],
"sortby" => $v['sortby'],
"sourceproductcode" => $v['sourceproductcode'],
"mastervariant" => $v['mastervariant']
);

Next, you need to edit the modify options page, otherwise, if you change options, it’ll remove your new field data.

When submitting this form, it passes these variables to product_modify.php:

section=options
mode=product_options_add
classid= your classid
productid = your productid
geid=”"

If you change add[is_modifier] (price modifier = ‘y’, else it’s blank), it rebuilds the variants by calling func_rebuild_variants in modules/Product_Options/func.php

//Rebuild variants: . . . . product_modify.php?productid=18&section=options&classid=71

In func_rebuild_variants, change the $_product[’prices’] $data variable to:

$data = array(
"productid" => $productid,
"quantity" => $p['quantity'],
"membershipid" => $p['membershipid'],
"variantid" => $variantid,
"price" => $p['price'],
"numpymnts" => $p['numpymnts'],
"paymentprice" => $p['paymentprice'],
"sortby" => $p['sortby'],
"sourceproductcode" => $p['sourceproductcode'],
"mastervariant" => $p['mastervariant']
);

This will keep your data from being lost in the new columns. And that’s it, as far as back end functionality for the multi pay option. Depending on how your templates are set up, you’ll probably want to use the new columns to force the “mastervariant” column to show up in the “starting at” price. Do this by ordering that query by mastervariant in descending order. The rest of the columns really come in handy when you need to see the full price such as in reports, modifying omniture code, and to produce export files where the fulfillment company wants to see the full amount instead of the per payment price.

Darren xcart | data backup | database | mysql | ecommerce
Aug 04, 2009 12:20 AM EDT

Making CSS layouts work in the 3 main browsers: IE6, IE7, and Firefox 2

I recently redesigned my photography website, The Lens Flare. I had Internet Explorer 7 and Firefox 2 installed, and thus wrote the site to make it work with those browsers. Once I had it working on those 2 browsers, I tried it on IE6 and the template was horribly screwed up. Here, I’ll explain what I had to change to make it look good in the 2 current browsers and IE6.

Apparently, IE6 has a bug people have dubbed the double padding bug or double margin bug. The problem can usually be fixed by using the CSS option: “display:inline” on your DIVs that have the double spacing problem. This fixed most of the spacing issues, but it didn’t fix them all.

To fix the last spacing problem, I had to resort to an Internet Explorer Kludge called conditional comments to include a separate CSS file when IE6 is loaded.

To do this, you put the following code after your other CSS files in your HEAD tag:

<!--[if IE 6]><link rel=”style sheet” href=”ie6.css” type=”text/css” media=”all” /><![endif]-->

This loads the ie6.css file when somebody is using IE6.

The main CSS file has the following directions for the col2 div:

.col2 {
width:338px;
position:relative; float:left;
margin:0px 0px 0px 5px; padding:0px;
display:inline;
}

The ie6.css file overrides col2 with the following directives:

.col2 {
width:338px;
margin:0px; padding:0px;
display:inline;
}

In IE6, floating the div to the left and adding a margin on the left side messed things up. From what I can tell, it started the location of the div in a slightly different place than IE7 and Firefox does and therefore has to be positioned differently to appear in the same place on the screen.

Also, another trick I learned while dealing with IE6’s limitations was a handly CSS tidbit called: “overflow:hidden”.

There are several places in my layout where I have a 2 pixel tall div with a background color to act as a horizontal rule. For example, this gray line:

.gray-line {
position:relative;
width:99%;
height:2px;
background-color:#ddd;
margin:0px; padding:0px;
overflow:hidden;
}

However, without the overflow:hidden aspect, IE6 renders a line about 5-8 pixels tall.

Lastly, “background-repeat: no-repeat” solved one last IE6 problem. Since it seems to use different heights for things, in places where I’m using a background image, the image would start to repeat itself again for about 2-3 pixels. Setting this directive on those areas solved that problem. Combine that with overflow:hidden and we’re good to go.

Darren css | browsers | web site format
Aug 04, 2009 12:12 AM EDT

Xcart 4.1 and CDSEO module creates bugs in the Review module

Xcart is a fairly popular e-commerce shopping cart program, and one of the add-on modules that you can buy from a third party company is called CDSEO. This rewrites all of the links to be SEF using a folder-style syntax instead of the regular ?variable=value syntax.

However, it causes some problems with X-Cart. One such problem is the Review Product form on the product detail page (product.php).

To fix this bug, you need to add hidden fields to the form instead of having them inside the form’s “action”.

In other words, change:

<form method=”post” action=”/product.php?mode=review&productid={$product.productid}” id=”reviewform”>

To:

<form method=”post” action=”/product.php?productid={$product.productid}” id=”reviewform” method=”post”>
<input type=”hidden” name=”productid” value=’{$product.productid}’ />
<input type=”hidden” name=”mode” value=”review” />

Next, you’ll need to edit vote.php at the document root of your Xcart install and add a slash at the beginning of the link.

So change:

func_header_location(”product.php?productid=$productid”);

to:

func_header_location(”/product.php?productid=$productid”);

This is because the CDSEO module creates a pseudo-directory and thus your browser thinks that it’s in that folder and tries to redirect you to the wrong path.

Darren xcart | bugs
Aug 04, 2009 12:06 AM EDT

Using GPG with RightScale and Amazon EC2

The idea behind using a service like RightScale in a cloud hosting service like Amazon’s EC2 is that you write a small program to install everything needed on your server. Because of this, you can dynamically turn servers on and off depending on your current traffic.

Where it gets difficult is when you need to install something that requires user input such as when signing a GPG key.

To get around this, you’ll need to come up with a solution that will allow you do finish the task without using user input.

In the example of signing GPG keys, instead I use the –always-trust parameter like this:

gpg –always-trust -ear ‘username’ test.txt

This allows me to encrypt a file in a script without having to answer the Yes/No question of whether I really want to encrypt it or not.

Normally, I would sign the key to avoid this question, but signing the key requires several questions to be answered and I’ve yet to find a way to script their answers.

Darren rightscale | amazon hosting | gpg keys
Aug 04, 2009 12:03 AM EDT

Counting occurances of a string with Grep

I noticed that one of my servers was using quite a bit more of its CPU resources than normal, yet my Analytics software wasn’t showing a spike in traffic. I have a rather large Apache access_log file, and I wanted to see how many times a particular bot scraped my web pages. Looking through it by hand isn’t practical since the log is over 1GB in size.

Instead, what I did was this simple grep command:

grep -c “myregex” access_log

In the quotes, I put the real string that I was searching for. The c flag refers to “Count”, which returns the number of times that regular expression occurs in the file.

In this case, the scraping program that I thought was the culprit had downloaded less than 100 web pages, but the true culprit had downloaded many more. It was using a browser’s User Agent so it’s either a really active visitor, a browser plugin, or a spider spoofing a real browser. To resolve this, I used IPTables to block their IP address. Problem solved.

Darren grep | programming | strings | counting
Aug 03, 2009 08:30 PM EDT

Ruby on Rails vs. PHP

I’m often surprised by the number of people that still have not heard of Ruby on Rails.

In case you haven’t heard of Rails, it’s a framework built upon the Ruby programming language. Ruby is completely object-oriented and suitable for many platforms and purposes. It can be run on all the major operating systems, and comes preinstalled on most modern flavors of Linux. Rails is a framework that makes developing web applications in Ruby take less time once you get past its learning curve.

To date, I’ve programmed in several languages. I wrote a web spider in Java, built a very popular tech support portal in ASP (in the top 3000 of Alexa’s ranking), have written countless export and database administration scripts in Perl, and have written a lot of applications in PHP such as a point of sale system, photography gallery, online appointment system, employee management system, file management system, and numerous other websites over the last 9 years.

I’ve felt that PHP has been somewhat stagnate for the past couple of years. Sure, there is version 5 that does a little more with objects and classes, but my impression is that the majority of PHP sites still run on version 4, which was released in May of 2000 even though version 5 came out in July of 2004. No doubt, PHP has been adding support for various extensions, and they’ve added additional functionality in their many sub-releases, but it’s essentially the same as it was 7 years ago.

In the first draft of this document, I stated that PHP replaced Perl, and Ruby on Rails will eventually replace PHP. Technically, that’s incorrect. PHP hasn’t replaced Perl. Rather, I believe that the developers of PHP based a lot of their functionality on Perl, but changed a few things based on what they intended to be a better system for web development. This is only my opinion, so please take that with a grain of salt as my experience developing web applications in Perl is limited.

What I can tell you with certainty is that the developers of Ruby on Rails did their homework. They’ve taken a look at all of the existing web development platforms such as Java, PHP, Perl, ASP, ASP.NET, Coldfusion, Python, etc and have a really good idea of the things web developers of these platforms had to do over and over again such as creating forms or writing dynamic database queries with optional fields in the where clause, etc. Either through personal experience or by viewing other’s code, I’m not sure, but they also knew that most ASP/PHP style sites with embedded code within HTML causes a lot of headaches on larger sites because it’s a lot harder to maintain and test effectively.

From there, they created a framework on top of the Ruby language that forces code to be separated into 3 distinct areas: The models contain database info, the controllers contain application logic, and the views contain the html templates. This makes applications more structured and easier to maintain. They also created a set of libraries that make other aspects of web development easier to deal with. ActiveRecord does a really good job of abstracting database queries. Not only does this make creating queries easier, but it makes it so the application will work for a number of different database servers without adding a bunch of kludges for each database server. There is also a feature called routes which reduces the need for GET variables in a URL string. Instead, URLs follow folder style syntax, which has been claimed in many places to be more search engine friendly.

Ruby on Rails has caused a stir in the web development community, and many businesses are moving from PHP development to Ruby on Rails development. Why? Because once you know Ruby on Rails, you can program an application faster than PHP.

In response, the PHP community is trying to catch up, but they have a long way to go, and in my opinion, they’re going to fall on their face. They aren’t unified. They aren’t creating 1 framework to rival RoR or the other main platforms such as ASP.NET or Java. I did a couple of searches and found over 40 different frameworks for PHP.

With over 40 to choose from, how can a person decide on the right one? There’s definitely a learning curve involved, so who has the time to learn 40 different frameworks? How many people are getting turned down for jobs because they know PHP, but not the right framework that the business is using? How many of these frameworks are going to still be supported in 2 or more years? The worst part of it is that many of the PHP frameworks (CakePHP comes to mind) openly claim to be a Rails clone. Why use a clone when you can use the real thing?

“United we stand, Divided we fall”.

Ruby on Rails is united. There is one framework to learn and enhance. PHP is divided with over 40 frameworks.

I still program in PHP for legacy sites, but new sites are being done in Ruby on Rails.

Ruby on Rails is not all fluffy clouds, girls fanning you with giant leaves, or whatever your personal paradise is, however.

It’s a huge pain to get the server set up just right, and overall, it isn’t as fast as raw PHP (or raw Ruby for that matter). Typically, the lower level your code is, the faster it is because it doesn’t have to compute as much. Rails has several layers of code sitting between your own code and the processor. It also has a pretty steep learning curve unless you’ve already programmed using a framework and are familiar with object oriented concepts. It’s also really new, which means that there isn’t a lot of support on the web for Rails, and many of the standard apps that people can expect to get on PHP aren’t available yet such as free forums, ecommerce sites, etc. There are a few available, but they aren’t developed as fully yet. It’s also more difficult to find a hosting company that supports Rails unless you have a dedicated server and do it yourself. They can be found, but there is only a handful so far.

Rails does provide some great features to scale a site, however. Sessions can be stored in a database, which makes it possible to have one web application span multiple servers and not worry about sessions getting lost. There’s support for caching at a page level and at a partial level (a partial in Rails is like an include or require in PHP). Currently, the best server setup uses a combination of Apache and Mongrel, a single-threaded web server designed to handle Rails applications. Apache’s proxy load balancer makes it possible to pass connections to any number of instances of Mongrel whether on the same or different servers, which makes it possible to scale a site quite easily.

Frameworks are the way to go, if you want the structure of your code to be standard and thus easier to get a new developer ramped up and productive faster. Ruby on Rails is ahead of the game and PHP is trying to catch up. Every day, people are switching from PHP development to Ruby, and unless they can come up with a unified framework to rival Rails, I believe they will lose a large percentage of their development community.

I’ve written a 2009 update to this article, also titled Ruby on Rails vs. PHP on a social network site that I wrote using Ruby on Rails.

Darren platforms | ruby on rails | php | frameworks | programming
Displaying posts 16 - 25 of 25 in total

 

 

 

 

Resource Links