A tiny REPL for PHP

Related tags

Command Line boris
Overview

Boris

A tiny, but robust REPL for PHP.

Code Climate Build Status

Announcement: I'm looking to add one or two additional collaborators with commit access. If you are actively involved in open source and have a GitHub profile for review, ping me on Twitter (@d11wtq) to express your interest. Experienced developers with active GitHub projects only.

Demo

Python has one. Ruby has one. Clojure has one. Now PHP has one, too. Boris is PHP's missing REPL (read-eval-print loop), allowing developers to experiment with PHP code in the terminal in an interactive manner. If you make a mistake, it doesn't matter, Boris will report the error and stand to attention for further input.

Everything you enter into Boris is evaluated and the result inspected so you can understand what is happening. State is maintained between inputs, allowing you to gradually build up a solution to a problem.

Note: The PCNTL function which is required to run Boris is not available on Windows platforms.

Why?

I'm in the process of transitioning away from PHP to Ruby. I have come to find PHP's lack of a real REPL to be frustrating and was not able to find an existing implementation that was complete. Boris weighs in at a few hundred lines of fairly straightforward code.

Usage

Check out our wonderful wiki for usage instructions.

Contributing

We're committed to a loosely-coupled architecture for Boris and would love to get your contributions.

Before jumping in, check out our Contributing contributing page on the wiki!

Contributing

We're using PHPUnit for testing. To run all the tests,

phpunit --bootstrap tests/autoload.php -c tests.xml

Core Team

This module was originally developed by Chris Corbyn, and is now maintained by Tejas Manohar, Dennis Hotson, and other wonderful contributors.

Copyright & Licensing

See the LICENSE file for details.

Comments
  • Dependencies update as a patch update

    Dependencies update as a patch update

    Hi,

    In v1.0.9, ext-readline, ext-pcntl and ext-posix were moved from suggested to required, thus preventing any libraries that requires boris from installing if any of the extensions are not installed.

    Considering the history of the composer.json file, and that the previous commit message (from v1.0.5 to v1.0.8) is Move PHP-ext from require to suggest section in composer.json, I'm curious as to what lead to this change. I'm assuming that require was the proper way to do it and not suggest.

    opened by tomzx 22
  • Composer can't find the package on github

    Composer can't find the package on github

    Composer looks for the dist version of the package in the wrong place:

    [Composer\Downloader\TransportException]
    The "https://api.github.com/repos/d11wtq/boris/zipball/31055b15e2d3fe47f31f6aa8e277f8f3fc7eb483" file could not be downloaded (HTTP/1.1 404 Not Found)
    
    opened by EloProf 17
  • Getting Boris into Packagist (take 2)

    Getting Boris into Packagist (take 2)

    Here's my 2nd attempt at getting boris composer / packagist ready. :-)

    The package name needed a vendor apparently, the name is now d11wtq/boris.

    I've also committed the composer vendor directory (normally you don't do this) basically so that end users can just check the repo out of git and run ./bin/boris. No need to composer install first.

    opened by dhotson 17
  • Segmentation Fault

    Segmentation Fault

    I am getting a segmentation fault whenever I run the following:

    $i = 123;
    print $i;
    

    Here is the error message:

    /usr/local/bin/boris: line 3: 81017 Segmentation fault: 11  /usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/boris/1.0.8/libexec/boris.phar "$@"
    PHP Notice:  fwrite(): send of 1 bytes failed with errno=32 Broken pipe in phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php on line 205
    PHP Stack trace:
    PHP   1. {main}() /usr/local/Cellar/boris/1.0.8/libexec/boris.phar:0
    PHP   2. require() /usr/local/Cellar/boris/1.0.8/libexec/boris.phar:10
    PHP   3. Boris\Boris->start() phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/bin/boris:15
    PHP   4. Boris\EvalWorker->start() phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/Boris.php:171
    PHP   5. Boris\EvalWorker->_write() phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php:147
    PHP   6. fwrite() phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php:205
    PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Socket error: failed to write data' in phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php:206
    Stack trace:
    #0 phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php(147): Boris\EvalWorker->_write(Resource id #20, '\x00')
    #1 phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/Boris.php(171): Boris\EvalWorker->start()
    #2 phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/bin/boris(15): Boris\Boris->start()
    #3 /usr/local/Cellar/boris/1.0.8/libexec/boris.phar(10): require('phar:///usr/loc...')
    #4 {main}
      thrown in phar:///usr/local/Cellar/boris/1.0.8/libexec/boris.phar/lib/Boris/EvalWorker.php on line 206
    

    I have the following modules installed and enabled. Do you think it is due incompatibility with xdebug?

    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    curl
    date
    dba
    dom
    ereg
    exif
    fileinfo
    filter
    ftp
    gd
    gettext
    hash
    iconv
    intl
    json
    ldap
    libsodium
    libxml
    mbstring
    mcrypt
    mhash
    mssql
    mysql
    mysqli
    mysqlnd
    odbc
    openssl
    pcntl
    pcre
    PDO
    pdo_dblib
    pdo_mysql
    PDO_ODBC
    pdo_pgsql
    pdo_sqlite
    pgsql
    Phar
    posix
    readline
    redis
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    standard
    sysvmsg
    sysvsem
    sysvshm
    tokenizer
    wddx
    xdebug
    xml
    xmlreader
    xmlrpc
    xmlwriter
    xsl
    yaml
    zip
    zlib
    
    [Zend Modules]
    Xdebug
    
    opened by cmckni3 11
  • Broken backwards compatibility

    Broken backwards compatibility

    It's probably too late to fix this but Version 1.0.9 breaks backwards compatibility by relying on additional dependencies:

    ext-readline: *
    ext-pcntl: *
    ext-posix: *
    

    The result of this (when combined with other work I was doing) was that it took down part of my website for almost an hour while I diagnosed the problem and fixed my composer.json to point directly to 1.0.8. Considering the release notes for 1.0.9 and 1.0.10 are "old array syntax" and "team bullets" I'm not sure why these extra dependencies are required

    However, to follow Semantic Versioning, the version number should have bumped to 2.0.0.

    opened by Gisleburt 11
  • Won't run on PHP 5.5, Linux Mint 16

    Won't run on PHP 5.5, Linux Mint 16

    Hi all,

    Tried the Phar and the git repo, can't get Boris to launch at all on Linux Mint 16, with PHP 5.5.3

    PHP Warning:  pcntl_signal() has been disabled for security reasons in /home/josh/Apps/boris/lib/Boris/Boris.php on line 141
    PHP Warning:  pcntl_fork() has been disabled for security reasons in /home/josh/Apps/boris/lib/Boris/Boris.php on line 148
    PHP Notice:  fwrite(): send of 1 bytes failed with errno=32 Broken pipe in /home/josh/Apps/boris/lib/Boris/EvalWorker.php on line 205
    PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Socket error: failed to write data' in /home/josh/Apps/boris/lib/Boris/EvalWorker.php:206
    Stack trace:
    #0 /home/josh/Apps/boris/lib/Boris/EvalWorker.php(88): Boris\EvalWorker->_write(Resource id #11, '?')
    #1 /home/josh/Apps/boris/lib/Boris/Boris.php(171): Boris\EvalWorker->start()
    #2 /home/josh/Apps/boris/bin/boris(16): Boris\Boris->start()
    #3 {main}
      thrown in /home/josh/Apps/boris/lib/Boris/EvalWorker.php on line 206
    

    That's my stacktrace when running bin/boris

    opened by girvo 11
  • more feedback when PCNTL functions are missing (e.g. with default OSX php)

    more feedback when PCNTL functions are missing (e.g. with default OSX php)

    git clone git://github.com/d11wtq/boris.git
    cd boris
    ./bin/boris
    

    and that's it, nothing, no prompt.

    PHP works pretty well, I use drush all the time.

    Any idea what could be wrong?

    $ php -v
    PHP 5.3.26 (cli) (built: Jul  7 2013 19:05:08)
    Copyright (c) 1997-2013 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
    
    opened by guaka 10
  • BORIS won't start

    BORIS won't start

    I get the following error when I try to start it. I cloned the repo, cd'ed and tried to run it.

    Dinos-MacBook-Pro:bin dinoangelov$ ./boris

    Fatal error: Call to undefined function Boris\pcntl_signal() in /Users/dinoangelov/Library/Developer/boris/lib/Boris/Boris.php on line 110

    opened by dangelov 9
  • Issue with kill signal

    Issue with kill signal

    Hello, I've a small issue when sending a SIGINT while running Boris. This is what happens when I Ctrl-C:

    [1] boris> PHP Warning:  stream_select(): unable to select [4]: Interrupted system call (max_fd=3) in /tmp/boris/lib/Boris/EvalWorker.php on line 158
    
    Warning: stream_select(): unable to select [4]: Interrupted system call (max_fd=3) in /tmp/boris/lib/Boris/EvalWorker.php on line 158
    

    I haven't really investigated yet, but do you know why is this happening? (I'm running php 5.4.12 on OSX) Thanks.

    bug 
    opened by MattKetmo 9
  • Could not exit from boris

    Could not exit from boris

    Using latest version

    
    [16:29 @ ~/www/boris] $ git lg
    fe10592 - (HEAD, origin/master, origin/HEAD, master) Merge pull request #55 from abackstrom/more-objectvars (6 weeks ago) Chris 'Chippie' Corbyn
    [16:30 @ ~/www/boris] $ git pull
    Already up-to-date.
    [16:32 @ ~/www/boris] $ boris
    [1] boris> :
    [1]     *> ;
    PHP Parse error:  syntax error, unexpected ':' in phar:///usr/local/bin/boris/lib/Boris/EvalWorker.php(133) : eval()'d code on line 1
    PHP Stack trace:
    PHP   1. {main}() /usr/local/bin/boris:0
    PHP   2. require() /usr/local/bin/boris:9
    PHP   3. Boris\Boris->start() phar:///usr/local/bin/boris/bin/boris:15
    PHP   4. Boris\EvalWorker->start() phar:///usr/local/bin/boris/lib/Boris/Boris.php:171
    
    Parse error: syntax error, unexpected ':' in phar:///usr/local/bin/boris/lib/Boris/EvalWorker.php(133) : eval()'d code on line 1
    
    Call Stack:
        0.0001     245288   1. {main}() /usr/local/bin/boris:0
        0.0005     259968   2. require('phar:///usr/local/bin/boris/bin/boris') /usr/local/bin/boris:9
        0.0017     433744   3. Boris\Boris->start() phar:///usr/local/bin/boris/bin/boris:15
        0.0034     509576   4. Boris\EvalWorker->start() phar:///usr/local/bin/boris/lib/Boris/Boris.php:171
    
     → false
    [2] boris> ^C^C^C
    
    [2] boris> exit;
    [3] boris> exit;
    [4] boris> exit;
    [5] boris> exit;
    [6] boris> exit;
    [7] boris> exit;
    [8] boris> exit;
    [9] boris> exit;
    [10] boris> exit;
    [11] boris> exit;
    [12] boris> exit;
    [13] boris> ^C^C^C^C^C
    
    [13] boris> 
    
    [13] boris> ^C^C^C
    
    [13] boris> ^C^C^C^C
    
    [13] boris> ^C^C^C^C
    
    [13] boris> 
    
    [13] boris> exit;
    [14] boris> exit;
    [15] boris> exit;
    
    opened by message 8
  • Add CleanInspector

    Add CleanInspector

    var_dump and var_export leave a lot to be desired on the readability front. I worked up a more robust inspector with the following features:

    • Per-type output formatting, aiming for maximal clarity with minimal cruft
    • Nested array and object output
    • Intelligent array truncation for > 10 items (to prevent accidental page spam)
    • Optional color-highlighting for each type, customizable on construction

    Really perks things up, IMHO. :-) Comments welcome!

    screen shot 2013-05-08 at 1 15 13 pm

    opened by irongaze 8
  • Adding '-a/--autoload' option

    Adding '-a/--autoload' option

    This PR adds a --autoload (shorthand -a) option to boris. Adding this option will make Boris automatically search for a autoload.php file and require it so that the user's classes are available immediately.

    Examples:

    Using -a option, autoload.php is required automatically:

    ~/my_composer_project$ boris -a
    Requiring autoload file: /Users/leonardoraele/my_composer_project/vendor/autoload.php
    [1] boris> 
    

    Not using -a option, boris works normally.

    ~/my_composer_project$ boris
    [1] boris> 
    

    Using -a option not in a composer project, nothing is loaded. Boris works normally.

    ~/my_composer_project$ cd ~
    ~$ boris -a
    No autoload file found.
    [1] boris> 
    
    opened by leonardoraele 0
  • Redefine class/functions

    Redefine class/functions

    A really good repl would allow redefine classes and functions.

    Since boris has a internal handling of error's seems reasonable that we could catch redeclare errors and starting again the session (and re applying), fixing this problem.

    What is your opinions about this?

    opened by jeanCarloMachado 0
  • Support strict types.

    Support strict types.

    PHP projects I'm working on lately are adding:

    declare(strict_types=1);
    

    to the top of every file, but I don't know how or if it's possible to enable this in boris.

    This isn't a huge issue assuming you test your code, but it's nice to have the same behavior for things I write in boris as the code I'm working on.

    $ boris

    [1] boris> declare(strict_types=1);
    [2] boris> function foo(): int { return '123'; }
    // NULL
    [3] boris> foo();
    // 123
    

    $ php -r "declare(strict_types=1); function foo(): int { return '123'; }; foo();"

    PHP Fatal error:  Uncaught TypeError: Return value of foo() must be of the type integer, string returned in Command line code:1
    Stack trace:
    #0 Command line code(1): foo()
    #1 {main}
      thrown in Command line code on line 1
    
    opened by glennpratt 0
  • Composer >1.3.0 compatibility

    Composer >1.3.0 compatibility

    Composer 1.3.0 now reloads PHP in order to disable XDebug. This results in the following error being generated whenever the library is used:

    PHP Warning:  Module 'pcntl' already loaded in Unknown on line 0
    
    Warning: Module 'pcntl' already loaded in Unknown on line 0
    

    other packages are affected by this too. more info:

    https://github.com/Homebrew/homebrew-php/issues/3896#issuecomment-271522581 https://github.com/sensiolabs/SensioDistributionBundle/pull/304/files

    opened by barchard 0
  • Basic Readline Completion

    Basic Readline Completion

    How It works:

    • Prefix all data sent to EvalWorker with a 1 byte command identifier can be either CMD_EVAL ("\0") or CMD_COMPLETE ("\1").
    • completiion function sends CMD_COMPLETE . substr($info['line_buffer'], 0, $info['end']) to eval worker
    • eval worker sends back completions as a JSON blob.

    Completion function inspired from https://github.com/erikdubbelboer/php-repl/blob/master/repl.php

    Remove some dead code, keep eval worker alive if evaluation fails.

    opened by NicolaF 0
Owner
null
Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies.

Takeout Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies. It's meant to be pair

Tighten 1.4k Jan 2, 2023
PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal.

PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal. ??

Nuno Maduro 32 Dec 26, 2022
PHP Reverse Shell > reverse-shell.php

PHP Reverse Shell > reverse-shell.php PHP Cmd Shell > cmd.php JPG cmd Shell > cmd.jpg /etc/passwd Pulling Shell > etc-passwd.php Configuration Pulling

Dark-Network 5 Feb 24, 2022
Web Shell Detector – is a php script that helps you find and identify php/cgi(perl)/asp/aspx shells.

Web Shell Detector – is a php script that helps you find and identify php/cgi(perl)/asp/aspx shells. Web Shell Detector has a “web shells” signature database that helps to identify “web shell” up to 99%. By using the latest javascript and css technologies, web shell detector has a light weight and friendly interface.

Maxim 763 Dec 27, 2022
CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

PHP Cron Expression Parser NOTE This fork has been deprecated and development moved to https://github.com/dragonmantank/cron-expression. More informat

Michael Dowling 4.9k Jan 5, 2023
🖥 Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.

Contents Minimum Requirements Installation Upgrading Usage Quick Setup Examples API Appearance Menu Title Colour Width Padding Margin Borders Exit But

PHP School 1.9k Dec 28, 2022
PHP's best friend for the terminal.

Running PHP from the command line? CLImate is your new best bud. CLImate allows you to easily output colored text, special formats, and more. Installa

The League of Extraordinary Packages 1.8k Dec 30, 2022
An Elegant CLI Library for PHP

Commando An Elegant PHP CLI Library Commando is a PHP command line interface library that beautifies and simplifies writing PHP scripts intended for c

Nate Good 793 Dec 25, 2022
Lovely PHP wrapper for using the command-line

ShellWrap What is it? It's a beautiful way to use powerful Linux/Unix tools in PHP. Easily and logically pipe commands together, capture errors as PHP

James Hall 745 Dec 30, 2022
Cilex a lightweight framework for creating PHP CLI scripts inspired by Silex

Cilex, a simple Command Line Interface framework Cilex is a simple command line application framework to develop simple tools based on Symfony2 compon

null 624 Dec 6, 2022
A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

Yo-An Lin 428 Dec 13, 2022
[ABANDONED] PHP library for executing commands on multiple remote machines, via SSH

#Shunt Inspired by Ruby's Capistrano, Shunt is PHP library for executing commands on multiple remote machines, via SSH. Specifically, this library was

The League of Extraordinary Packages 436 Feb 20, 2022
A PHP library for command-line argument processing

GetOpt.PHP GetOpt.PHP is a library for command-line argument processing. It supports PHP version 5.4 and above. Releases For an overview of the releas

null 324 Dec 8, 2022
An object-oriented option parser library for PHP, which supports type constraints, flag, multiple flag, multiple values, required value checking

GetOptionKit Code Quality Versions & Stats A powerful option parser toolkit for PHP, supporting type constraints, flag, multiple flag, multiple values

Yo-An Lin 140 Sep 28, 2022
PHP Version Manager for the CLI on Windows

This package has a much more niche use case than nvm does. When developing on Windows and using the integrated terminal, it's quite difficult to get those terminals to actually listen to PATH changes.

Harry Bayliss 49 Dec 19, 2022
PHP CLI tool which allows publishing zipped MODX extra to modstore.pro marketplace

MODX Extra Publisher PHP CLI tool which allows publishing zipped MODX extra to modstore.pro marketplace. Installation global? local? To install packag

Ivan Klimchuk 3 Aug 6, 2021
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
Twitter raffles in the command line, with PHP and minicli

Rafflebird Rafflebird is a highly experimental CLI application for giveaways / raffles on Twitter, built in PHP with Minicli. Disclaimer: The recent s

Erika Heidi 33 Nov 16, 2022