A tiny REPL for PHP

Related tags

Miscellaneous 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
Tiny PHP library providing retry functionality with multiple backoff strategies and jitter support

JBZoo / Retry 4 retry strategies (plus the ability to use your own) Optional jitter / randomness to spread out retries and minimize collisions Wait ti

JBZoo Toolbox 6 Dec 19, 2022
Tiny, fast and simple PHP boilerplate built on top of FlightPHP

BlessPHP Tiny, fast and simple PHP boilerplate built on top of FlightPHP. Good enough to use as skeleton for prototypes and some pet-projects. The nam

Anthony Axenov 2 Sep 20, 2022
The Current US Version of PHP-Nuke Evolution Xtreme v3.0.1b-beta often known as Nuke-Evolution Xtreme. This is a hardened version of PHP-Nuke and is secure and safe. We are currently porting Xtreme over to PHP 8.0.3

2021 Nightly Builds Repository PHP-Nuke Evolution Xtreme Developers TheGhost - Ernest Allen Buffington (Lead Developer) SeaBeast08 - Sebastian Scott B

Ernest Buffington 7 Aug 28, 2022
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

null 272 Dec 22, 2022
PHP Meminfo is a PHP extension that gives you insights on the PHP memory content

MEMINFO PHP Meminfo is a PHP extension that gives you insights on the PHP memory content. Its main goal is to help you understand memory leaks: by loo

Benoit Jacquemont 994 Dec 29, 2022
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

null 258 Sep 15, 2022
A multithreaded application server for PHP, written in PHP.

appserver.io, a PHP application server This is the main repository for the appserver.io project. What is appserver.io appserver.io is a multithreaded

appserver.io 951 Dec 25, 2022
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

Lodash PHP 474 Dec 31, 2022
A PHP 5.3+ and PHP 7.3 framework for OpenGraph Protocol

Opengraph Test with Atoum cd Opengraph/ curl -s https://getcomposer.org/installer | php php composer.phar install --dev ./vendor/atoum/atoum/bin/atoum

Axel Etcheverry 89 Dec 27, 2022
A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch screens with a resolution of 1024x600 connected to a Raspberry Pi.

EDStatusPanel A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch scr

marcus-s 24 Oct 4, 2022
🐘 A probe program for PHP environment (一款精美的 PHP 探針, 又名X探針、劉海探針)

Simplified Chinese | 简体中文 Traditional Chinese(Taiwan) | 正體中文(臺灣) Traditional Chinese(Hong Kong) | 正體中文(香港) Japanese | 日本語 ?? X Prober This is a probe

Km.Van 1.2k Dec 28, 2022
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

null 464 Dec 28, 2022
PHP generics written in PHP

PHP generics written in PHP Require PHP >= 7.4 Composer (PSR-4 Autoload) Table of contents How it works Quick start Example Features Tests How it work

Anton Sukhachev 173 Dec 30, 2022
PHP exercises from my course at ETEC and some of my own play-around with PHP

etec-php-exercises PHP exercises from my course at ETEC and some of my own play-around with PHP Translations: Português (BR) Projects Project Descript

Luis Felipe Santos do Nascimento 6 May 3, 2022
GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

Shivam Mathur 2.4k Jan 6, 2023
php-echarts is a php library for the echarts 5.0.

php-echarts 一款支持Apache EChart5.0+图表的php开发库 优先ThinkPHP5/6的开发及测试。 Apache EChart5.0已经最新发布,在视觉效果、动画效果和大数据展示方面已经远超之前的版本; 故不考虑EChart5.0之前版本的兼容问题;建议直接尝试5.0+

youyiio 5 Aug 15, 2022
Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Ry-Zen 7 Aug 21, 2022
Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API.

Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API. Check out the latest API documentation. Add library in a composer.json file.

Patrick Falize 6 Oct 7, 2021
churn-php is a package that helps you identify php files in your project that could be good candidates for refactoring

churn-php Helps discover good candidates for refactoring. Table of Contents What Is it? Compatibility How to Install? How to Use? How to Configure? Si

Bill Mitchell 1.3k Dec 22, 2022