Page 1 of 1

any PHP CLI books, references ?

Posted: Wed Jan 03, 2007 12:38 am
by saumya
Can anybody help me with some good references to CLI of PHP.
thanking you
saumya

Posted: Wed Jan 03, 2007 5:24 am
by onion2k
10 seconds of Googling turned up http://www.php-cli.com/

That site has an impressive number of adverts on it. :lol:

Posted: Wed Jan 03, 2007 5:37 am
by Chris Corbyn
There really aren't huge differences. The differences onyl affect how arguments are given to scripts (i.e. no GET/POST), how you display data to the user and the fact you can work with STDIN/STDOUT. Obviously, you can't set cookies, do sessions or any other HTTP-based things but you don't really need to because CLI behaves differently anyway - you can keep a session open indefinitely without the standard 30 second timeout.

Interesting things to look at in the manual, if you have the extensions installed:

http://uk2.php.net/ncurses (be sure to check out the user comments -- someone posted a tetris implementation in PHP)
http://uk2.php.net/readline

Those two tools allow you to create some very effective command line applications.

Posted: Wed Jan 03, 2007 6:15 am
by onion2k
d11wtq wrote:you can keep a session open indefinitely without the standard 30 second timeout.
That carries it's own issues. You need to be extra careful with loops and recursion, and you should be vigilant that you're unsetting variables and connections that are no longer needed rather than just letting PHP clean up at the end, otherwise you might well hit the PHP memory limit and your script will slow right down.