Coder Social home page Coder Social logo

iphp's People

Contributors

apinstein avatar bermi avatar dexterthedragon avatar funkatron avatar sebastianbergmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iphp's Issues

Make iphp multi-line aware

Maybe use the built-in PHP parser to see if we're in the middle of a statement and allow multi-line input until a ; or some other signal is entered on a single line?

Or maybe have a multi-line internal command? like


foreach ($a as $b) {
print $b;
}
;

Add more content-awareness to autocomplete.

I have an idea to use token_get_all() to parse the input and do lexical analysis on the code entered so far to improve the autocomplete list.

So if you have a class Foo with methods bar() and baz() you would see:

$foo = new Foo;
$foo->b
bar baz

This could be done with real-time reflection.

Status

@apinstein will you please give a status update

Where is the project at?
Where is the project going?
How much time can you commit to this project?
Known PHP version support?
Any other dependencies?

I installed and immediately readline is not working which is should so I haven't looked at it any closer thought I might get your response first.

I've been using facebook's phpsh and recently made some modifications realizing that there really isn't much preventing us from doing it all in php. Started playing with ipython and why don't we have iphp was the thought that came to mind. Hence a google search landed me here.

Interested? Plausible? Know of any other similar projects perhaps?

Looking forward to hearing your thoughts,.

add a "requirements" section in the readme

the readme file should list the requirements for running iphp.

So far, I can see PHP 5 >= 5.1 is needed because of use of the readline_callback_handler_install function. and, php-cli is also needed.

also, PHP must be compiled with option --with-readline

create PEAR package

A simple PEAR package for this project would make it really easy for php-ers to have a one-line install that will put the iphp bin in their path.

Eventually the (pearfarm project)[http://github.com/fgrehm/pearfarm] will help with that, but it's not quite ready yet...

Anyone wanna take a crack at the PEAR package?

Undefined function readline_callback_handler_install

I have readline installed, not sure why I am getting an undefined function call. System information and command output is below.

 $ php -v
PHP 5.2.11 (cli) (built: Nov 17 2009 19:18:54) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with the ionCube PHP Loader v3.3.1, Copyright (c) 2002-2009, by ionCube Ltd., and
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
 $ uname -a
Linux eric-desktop.local 2.6.30.9-102.fc11.x86_64 #1 SMP Fri Dec 4 00:18:53 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

$ ./iphp
Welcome to iphp, the interactive php shell!

Features include:
- autocomplete (tab key)
- readline support w/history
- automatically wired into your project's autoload

Enter a php statement at the prompt, and it will be evaluated. The variable $_ will contain the result.

Example:

> new ArrayObject(array(1,2))
ArrayObject Object
(
    [0] => 1
    [1] => 2
)

> $_[0] + 1
2

PHP Fatal error:  Call to undefined function readline_callback_handler_install() in /home/eric/Source/iphp/iphp.php on line 191
PHP Stack trace:
PHP   1. {main}() /home/eric/Source/iphp/iphp:0
PHP   2. iphp::main($options = array ()) /home/eric/Source/iphp/iphp:7
PHP   3. iphp->readline() /home/eric/Source/iphp/iphp.php:276
PHP   4. iphp->myReadline() /home/eric/Source/iphp/iphp.php:209

Fatal error: Call to undefined function readline_callback_handler_install() in /home/eric/Source/iphp/iphp.php on line 191

Call Stack:
    0.0006      94752   1. {main}() /home/eric/Source/iphp/iphp:0
    0.0031     203216   2. iphp::main(array ()) /home/eric/Source/iphp/iphp:7
    0.0291     755904   3. iphp->readline() /home/eric/Source/iphp/iphp.php:276
    0.0291     755904   4. iphp->myReadline() /home/eric/Source/iphp/iphp.php:209

Add support for closures, loops, classes in REPL

This was bugging me for awhile and i hacked away for about 2.5 hours trying to figure out a work about but
example:

> $foo = function() {return 'bar';}
> 
Uncaught exception with command:
Fatal error executing php: PHP Fatal error:  Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo:18
Stack trace:
#0 /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo(18): serialize(Array)
#1 {main}
  thrown in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo on line 18

Exception: Serialization of 'Closure' is not allowed in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo on line 18

Call Stack:
    0.0004     635040   1. {main}() /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo:0
    0.0009     637576   2. serialize() /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.U3N9Oo:18

Same goes for defining functions and classes
function:

> function foo() {return 'bar';}
> 
Uncaught exception with command:
Fatal error executing php: PHP Parse error:  syntax error, unexpected T_STRING, expecting '(' in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.8CUHcL on line 12

Parse error: syntax error, unexpected T_STRING, expecting '(' in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.8CUHcL on line 12
> 

Classes:

> class Foo {}
> 
Uncaught exception with command:
Fatal error executing php: PHP Parse error:  syntax error, unexpected T_CLASS in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.Pk4qgL on line 12

Parse error: syntax error, unexpected T_CLASS in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.Pk4qgL on line 12
> 

While i had a work around working the storing of $_ and $__out are not possible when you create a a special case even "foreach" will explode using serialization

foreach(range(0,10) as $i) { echo $i; }
> 
Uncaught exception with command:
Fatal error executing php: PHP Parse error:  syntax error, unexpected T_FOREACH in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.mXsYfJ on line 12

Parse error: syntax error, unexpected T_FOREACH in /private/var/folders/oQ/oQhij0hDFVOxzm9dMI9EC++++TI/-Tmp-/iphp.command.mXsYfJ on line 12
> 

Solution is avoid serialization and store the code input unserialized in a file and keep appending to it and re-executing, As for returning output some string parsing may be in order to find variables and var_dump-ing them may be in order or just rely or just print tokenize the last returnable line;

edit: fixed typo's my brain is fried

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.