PHP to Ruby

Learning Ruby through PHP examples

Opening up a Ruby Shell | Your first step with learning Ruby

May 3, 2018

In order to get started with Rails, let’s go over the differences between PHP and Ruby at the language level. Here’s where I’ll save you a mad StackOverflow chase trying to figure out how the heck Ruby can understand what you’re writing.

There’s some implict rules to Ruby that don’t exist in PHP, to make your life easier. It’s not hard. If anything it’s easier than PHP. So congrats, you’re already proficient at a language that’s harder to pick up than Ruby. You’ll get this.

In the following example and for the rest of the examples in this series you’ll be able to follow along in your own command line with Ruby’s built in sandbox.

In order to start a new instance of a Ruby interpreter, simply run irb in your terminal:

$ irb
2.4.3 :001 >

Boom, we have a Ruby shell in our Terminal. No gem dependencies required.

The same applies to PHP, although it’s just a different command to start the interactive mode:

php -a

And it’ll start a new PHP shell in your terminal like this:

$ php -a
Interactive shell
php >

That’s it! I recommend opening up 2 tabs or 2 different windows of your terminal, so you can switch back and forth between the languages.