Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a simple php shell for windows?

Is there a command line php shell available for windows? I looking for something similar to the python shell, that will allow me to open and immediately begin executing code.

like image 794
ewok Avatar asked Dec 12 '11 21:12

ewok


2 Answers

There is the windows command line for PHP: http://php.net/manual/en/install.windows.commandline.php

like image 63
Jonathan M Avatar answered Oct 12 '22 01:10

Jonathan M


Try this:

<?php
$fh = fopen('php://stdin', 'r');
$cmd = '';
$bcLvl = 0;
while (true)
{
    $line = rtrim(fgets($fh));
    $bcLvl += substr_count($line, '{') - substr_count($line, '}');
    $cmd.= $line;
    if ($bcLvl > 0 or substr($cmd, -1) !== ';')
    continue;
    eval($cmd);
    $cmd = '';
}

Save this code to a file (eg shell.php) and then run it from console:

php shell.php

Hit CTRL+C to exit.

like image 24
Pavle Predic Avatar answered Oct 12 '22 00:10

Pavle Predic