Jump to content

Ruby on Rails VS. PHP


Liquid Fire

Recommended Posts

you kinda need to remember though that the examples given in this topic are just that - and that is REALLY skimming on the surface of what a framework can do in one small area of your site. But consider stuff like validation, RSS, AJAX, Emailing, nice URL's for SEO, amongst many many many other things - all areas that time after time get asked about in terms of "how do I do this?" - though whilst its still advisable to find out, a framework will do much of this sort of stuff for you.

 

your example is pretty much there, although like 448191 says, it's better to delegate responsibility elsewhere rather than doing any crunching within. so you might have a model class called 'User' that extends the 'Model' class (and any class extending 'Model' will also have the same methods available which is where the usefulness really comes in):

 

<?php

class Model
{
   public $tableName = null;

   function get($conditions)
   {
      $query = "SELECT * FROM {$this->tableName} WHERE $conditions";

      // rest of code here

      return $result;
   }

   private function __call($name, $param)
   {
      if(substr($name, 0, 5) == "GetBy")
      {
         $field = strtolower(substr($name, 5));
         $conditions = "$field = '{$param[0]}'";

         $result = $this->get($conditions);
      }
      
      return $result;
   }
}

class User extends Model
{
   public $tableName = 'users';
}

$myuserinstance = new User();
$user = $myuserinstance ->GetByUsername('redbullmarky');
?>

 

but yeah - ultimately you've got the gist. useful, huh? ;D

 

Cheers

Mark

Link to comment
Share on other sites

yeam pretty useful.  well first of all, what is SEO?  Aalidation, yea is would be nice not to have to deal with form validation each time i have a form but i can just build and for validator myself is need be.  RSS is not a feature i am worried about as i feel there is no real need for it right now.  AJAX is something i want to learn so it would make no sense in me using a framework to do if for me.  I am going to be build an email class seperately anyways.  This is something i am going to be pitching at work since right now we are rebuild some of the section of our website from scratch and fell something like Cake will be useful and maybe they will not see switching to ruby for Rails as needed becuase Cake can do most of the thing ruby on rails can.

Link to comment
Share on other sites

well first of all, what is SEO? ... Cake will be useful and maybe they will not see switching to ruby for Rails as needed becuase Cake can do most of the thing ruby on rails can.

 

SEO = search engine optimisation. One of the weird things with many of these frameworks is that you'll probably never use $_GET ever again - but more of a segment approach. It's weird at first, but when you get used to it, you realise how much crap you throw in the URL. example?

 

 

would become:

 

which from what i've both read and experienced, REALLY helps getting those pages indexed. Google is not really a fan of pages that have lots of URL parameters - so simplifying it into a more readable fashion does wonders. A look at the URL's of blogs and many "Web 2.0" sites will show you how it's not all about the ? and the &

 

as for your last point(s), dont just see the examples (RSS/validation/AJAX) as all there is - those were (personal) examples of those tasks that when I used to sit facing another project, I thought "*sigh* not another bloody contact form/Rss feed, etc" - now I can just get on with app/site specific stuff.

 

In my opinion, Rails (and Ruby) itself is sideways comparable to Cake (and PHP). If you know PHP, stick with it as Ruby doesnt REALLY offer any additional benefits (due to my old argument about the languages being more powerful than their results). As a beginner, maybe one might go either way and both ways would be fine - however, when the ultimate gain is to earn money and put bread on the table, best to stick with what you know rather than tackling "that" learning curve again.

 

And in my other opinion - if Cake doesn't do something that Rails can - write some code to make it! That's much easier than learning a whole new language and starting from the bottom of the ladder again.

 

Cheers

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.