Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes from various committers #5

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
90d53b1
Don't try to merge abbrev tables if `php-mode-abbrev-table' is unbound
Jan 16, 2011
1bb8763
Move point to inferior php buffer
Jan 16, 2011
9e57494
Fix missing quote
Jan 16, 2011
7bd5ecf
Use `apply' to pass php repl program arguments
Jan 16, 2011
6a501ad
Removed need to explicitly end lines with backslashes inside matched …
bobthecow Mar 16, 2010
0c9ab04
Combined curleys and parens logic into a token stack, allows matching…
bobthecow Mar 16, 2010
2510803
Continue when user enters a blank line (rather than exiting). User ma…
bobthecow Mar 16, 2010
73d0d12
Restart PHP process after abnormal exit
Apr 29, 2011
b9fc57a
Setq symbol before using it
Apr 29, 2011
ebbb46c
Don't change buffer and window when visiting inferior-php-buffer
Apr 29, 2011
b37af2c
Merge remote-tracking branch 'jmhobbs/master'
Apr 29, 2011
95a9dfe
Fix typo in defgroup prefix
Jul 10, 2011
b2cb936
Use inferior php buffer, not sql buffer
Jul 10, 2011
ce52384
Added check for PHP_INCLUDE_PATH environment variable.
niclashoyer Mar 5, 2012
3bf486b
Merge pull request #1 from niclashoyer/ce52384e033af0793290981882dc1c…
Mar 18, 2012
646c51d
Fixed bug in run-php that occured when php-repl-program-arguments is
Jul 17, 2012
e400ca6
Pulled in changes from dmj fork.
Jul 17, 2012
0bcb8b7
Set local comint-related variables.
kalifg Jul 17, 2012
a7167af
adding setter for options
Nov 7, 2012
ea3ef62
Merge remote-tracking branch 'kalifg/master'
Nov 7, 2012
cc5d2e0
making setOptions public
Nov 7, 2012
f0eec4e
changing output of an array to print_r and adding a showtime option t…
Feb 21, 2013
3dac455
taking readline out of options and making it part of the class
Jun 26, 2013
1917d5b
reorganizing files for use with composer
Jul 6, 2013
d8caed5
adding another example
Jul 6, 2013
e25103c
renaming PHP_Repl to PHPRepl
Jul 6, 2013
4eb8398
changes to readme to support the composer installation method
Jul 6, 2013
6ca1da8
changing references of PHP_Repl to PHPRepl
Jul 6, 2013
7500788
fixing some bugs that may have been added by namespaces
Jul 7, 2013
0e3dfd7
fixing bug in sugar method ,l
Jul 7, 2013
68548d0
making the output functions configurable through the options array
Feb 4, 2014
8b7dda5
removing auto saving of options
Feb 5, 2014
2159b96
fixing bug with setting options
Feb 5, 2014
2785ddb
separating printers from options. also making some sensible functions
Feb 14, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
65 changes: 25 additions & 40 deletions README.mkd
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
What is PHP_Repl?
What is PHPRepl?
=================
PHP_Repl is a read-eval-print loop for PHP, written in PHP. It aims to be light, clean, modern, object-oriented, and to leverage the existing features of PHP wherever possible.
PHPRepl is a read-eval-print loop for PHP, written in PHP. It aims to be light, clean, modern, object-oriented, and to leverage the existing features of PHP wherever possible.

Installation
============

$ git clone git://github.com/ieure/php_repl.git
$ cd php_repl
$ pear package
$ pear install PHP_Repl*tgz
The library is available through Composer, so its easy to get it. Simply add this to your `composer.json` file:

"require": {
"pmeth/php_repl": "dev-master"
}

And run `composer install`

Usage
=====
When you fire up PHP_Repl, you’re greeted with a prompt:
When you fire up PHPRepl, you’re greeted with a prompt:

php>

Expand Down Expand Up @@ -48,8 +51,8 @@ Uncaught Exceptions are caught and dumped:
exception 'Exception' with message 'Test 123' in /Users/ieure/Projects/php_repl/PHP/Repl.php(143) : eval()'d code:1
Stack trace:
#0 /Users/ieure/Projects/php_repl/PHP/Repl.php(143): eval()
#1 /Users/ieure/Projects/php_repl/PHP/Repl.php(62): PHP_Repl->run()
#2 /Users/ieure/Projects/php_repl/testrepl(20): PHP_Repl->__construct(Array)
#1 /Users/ieure/Projects/php_repl/PHP/Repl.php(62): PHPRepl->run()
#2 /Users/ieure/Projects/php_repl/testrepl(20): PHPRepl->__construct(Array)
#3 {main}
php>

Expand Down Expand Up @@ -79,16 +82,16 @@ Documentation
-------------
Doc blocks can be accessed with `,d`:

php> ,d PHP_Repl
php> ,d PHPRepl
/**
* PHP_Repl
* PHPRepl
*
* @package PHP_Repl
* @package PHPRepl
* @author Ian Eure <[email protected]>
* @version @package_version@
*/
'---'
php> ,d PHP_Repl::read
php> ,d PHPRepl::read
/**
* Read input
*
Expand Down Expand Up @@ -129,33 +132,33 @@ As mentioned, input is slightly altered before it is evaluated. Since this may p

Reuse
=====
You can reuse PHP_Repl in your own projects.
You can reuse PHPRepl in your own projects.

require_once 'PHP/Repl.php';
require_once 'PHPRepl.php';

function do_stuff()
{
if ($debug_condition) {
$repl = new PHP_Repl();
$repl = new PHPRepl();
$repl->run();
}
}

The REPL will have access to whatever scope your function does. If you invoke it from an object method, be aware that `$this` is always the PHP_Repl instance, not your object.
The REPL will have access to whatever scope your function does. If you invoke it from an object method, be aware that `$this` is always the PHPRepl instance, not your object.


Passing Scope
-------------

If you would like to pass additional variables into the REPL’s scope, you may include them in an array passed to run().

require_once 'PHP/Repl.php';
require_once 'PHPRepl.php';

class StuffDoer {
function do_stuff()
{
if ($debug_condition) {
$repl = new PHP_Repl();
$repl = new PHPRepl();
$repl->run(array('_caller' => $this));
}
}
Expand All @@ -164,7 +167,7 @@ If you would like to pass additional variables into the REPL’s scope, you may

Configuration
=============
PHP_Repl stores its configuration in `$HOME/.phpreplrc`. A default file will be created for you if none exists. Any options you set while the REPL is running will be written out when you quit it.
PHPRepl stores its configuration in `$HOME/.phpreplrc`. A default file will be created for you if none exists. Any options you set while the REPL is running will be written out when you quit it.

The following options are recognized:

Expand All @@ -176,9 +179,9 @@ The following options are recognized:
Dangers
=======

1. The evaluated code is run in the same process as PHP_Repl, so if you evaluate something which causes a fatal error, PHP_Repl will terminate. Sorry.
1. The evaluated code is run in the same process as PHPRepl, so if you evaluate something which causes a fatal error, PHPRepl will terminate. Sorry.
2. Output buffering is used to capture anything printed by eval’d code. If you have code which produces output over a long period of time, you may not see the results right away. Use `flush()`.
3. Certain settings are enforced by PHP_Repl. You can’t change the values of:
3. Certain settings are enforced by PHPRepl. You can’t change the values of:
1. `display_errors`. It’s always on.
2. `html_errors`. Always off.
3. `error_reporting`. Always `E_ALL | E_STRICT`.
Expand All @@ -187,24 +190,6 @@ Dangers
6. The output buffer’s callback method.


Emacs Integration
=================
Because I really like Emacs, and enjoy the integration other languages (e.g. Common Lisp, Python, etc) have with it, I put together `phprepl.el`. It’s incomplete and may be buggy.

It provides `run-php`, which will fire up the PHP REPL of your choice (not just PHP_Repl, it should work with any interactive PHP tool). It has the beginnings of a minor-mode to send regions, buffers, etc to the REPL for evaluation, but this isn’t finished yet.

Installation
------------
Drop `php-repl.el` somewhere in your `load-path` and `(require 'php-repl)`.

Configuration
-------------
It’s customizable; `M-x customize-group RET phprepl RET`. Point `php-repl-program` at `PHP/Repl.php`.

Usage
-----
`M-x run-php` will fire PHP_Repl up in a `*php*` buffer. Type and be happy.


Alternatives
============
Expand Down
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "pmeth/php_repl",
"description": "A command line REPL (Read-Evaluate-Print-Loop) for PHP written in PHP.",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Ian Eure",
"email": "[email protected]"
},
{
"name": "Peter Meth",
"homepage": "http://softersoftware.com"
}
],

"require": {
"php": ">=5.3.0"
},

"autoload": {
"psr-0": {
"PHPRepl": "src/"
}
}
}
123 changes: 0 additions & 123 deletions data/php-repl.el

This file was deleted.

9 changes: 9 additions & 0 deletions examples/example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use PHPRepl\PHPRepl;

require __DIR__ . '/../vendor/autoload.php';


$repl = new PHPRepl();
$repl->run();
29 changes: 29 additions & 0 deletions examples/php-repl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php // -*- mode: php -*-

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* Wrapper script for invoking PHPRepl
*
* PHP version 5
*
* @category PHP
* @package Repl
* @author Ian Eure <[email protected]>
* @copyright 2009 Ian Eure.
* @version Release: $Id$
* @filesource
*/

// Add environment variable PHP_INCLUDE_PATH to include_path if it exists.
$includePath = getenv('PHP_INCLUDE_PATH');
if ($includePath !== false) {
set_include_path(get_include_path().':'.getenv('PHP_INCLUDE_PATH'));
}

require_once __DIR__ . '/../src/PHPRepl/PHPRepl.php';
$__repl__ = new \PHPRepl\PHPRepl();
$__repl__->run();

?>
Loading