48

How do you start the Interactive Console for ruby and php

8 Answers 8

96

For ruby, you want the 'irb' command.

For python, you can enter interactive mode with the 'python' command.

For php, you enter a basic interactive mode with 'php -a'. Because of its limitations, other interactive shells have sprung up. PHP-Shell is one of them.

Sign up to request clarification or add additional context in comments.

Comments

5

Also, if you are working with a Ruby On Rails project you could use

ruby script/console

from your Rails application root. This is a good approach since you get an interactive ruby shell and the advantage is that loads the entire application stack for you. Pretty handy if you are testing your new code or trying to debug something.

1 Comment

ruby script/rails console (rails version > 3)
2

php doesn't lend itself very well to an interactive shell, because you can't redefine functions and classes. So while there is an interactive shell available, it's not very useful.

Comments

1

Make sure you have php5-cli installed and type 'php -a' at the command line.

Comments

1

you are looking for phpsh same as irb for ruby. php-cli allow you to run scripts for the command line like

myserver> php -r "echo 'hola mundo';" 

so what you are asking and all replies about php-cli are different. also php-cli has it own php.ini that allow you to have differents configurations depends of run php over httpd (like apache) or in bash

saludos

Comments

1

There is an excellent script for PHP that allows you to run a php console on a local website.

http://seld.be/notes/php-console-in-your-browser

There's obvious security implications here, but if it's only accessible locally, then there's no need to worry.

Really saves time if you want to double check the function behaviour, or to isolate a piece of code and diagnose what happens.

Comments

1

For a console with a rails 3.x+ project loaded

rails c

this is shorthand for ruby scripts/rails console

See more abbreviations here: http://xyzpub.com/en/ruby-on-rails/3.2/abkuerzungen.html

Comments

0

In php its php or php-cli - different name in different installations

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.