This is a Note, published Monday, March 7, 2011 – 9:15 AM

When you do a lot of development in PHP, sometimes you want to test one or two lines of function – quickly. This is where I created test.php file, wrote something in it, and test it with a browser, but it’s such a hassle. When I heard that PHP supports interactive mode, my heart jumped with joy. The thing is, running php interactive mode with php -a requires PHP to be compiled with readline library – which is not included by default in current Mac or Windows PHP version.

Fortunately for all of us, Stefan Fischer has created a very nice script that we can use to emulate interactive mode without recompiling PHP. The script, phpa-norl (php -a noreadline) is available in his website http://www.fischerlaender.net/php/phpa-norl . Download it now, it would make your life easier.

Before running the script, check if you have given permission for it to be executed, do a quick chmod 744 phpa-norl. Then run it with ./path/to/phpanorl. Alternatively, you can create .profile file in your home folder and export a new PATH so you can run it from everywhere.

via Run PHP interactive mode in Mac OS X – Blog « Rick Christie | Web designer & developer.

Annunci