This project contains (among other things) a read-eval-print loop (REPL) for the PHP language.
- Evaluates expressions in the global scope so global variables are accessible.
- Requires no local or global variables; won't clobber anything.
- Handles all types of errors and exceptions without exiting.
- Can be configured via .htaccess files.
- Has history support via readline, and in-REPL result history variables.
- In-REPL tab completion and documentation for everything.
- Deals correctly with PHP statements vs. expressions.
- Optional colored output.
- Configurable, extensible printer for pretty-printing PHP objects.
- Configurable pager (pipe output through arbitrary shell command).
- Easily extended, with programmatic access to most REPL functionality.
The REPL was designed to work with the Wigwam classloader. The -p
command line option allows the inclusion of other
classloaders prior to loading the Wigwam classloader, but tab completion may
not work for those classes. Once these classes have been loaded, though, the tab
completion mechanism will know about them.
Note: Files included via the -p
option do not run in the global scope.
- PHP 5.3 or better
- Readline PHP module
Assuming /usr/local/lib/php is in your PHP include path, and /usr/local/bin is in your shell path, I'd do something like this:
$ cd /usr/local/lib/php
$ git clone git://github.com/micha/wigwam.git Wigwam
$ cd Wigwam
$ ln -s `pwd`/console /usr/local/bin/console
See the man page here.
Wigwam is a PHP remote procedure call (RPC) framework. The idea is that the serverside PHP code contains only business logic---no HTTP, JSON, or HTML producing code required. Wigwam exposes public static methods of specified API classes to the client.
- API class methods are normal PHP functions. They take PHP data arguments and return PHP data.
- Calling convention on the client (JavaScript client library included) is
the same as on the server. The function
MyNS\Foo::bar(mixed $x)
could be called from the client JavaScript asWigwam.sync.MyNS.Foo.bar("asdf")
(for synchronous requests---async is also implemented). - Exceptions can be thrown in the PHP API class and caught in the client JavaScript environment.
- RESTful transport.
- Automatic content negotiation, anti-CSRF token management, etc.
- HTTP-related configuration is via docstring annotations. For example the
@verb
annotation tells the server which HTTP method to use when making the request. - Authorization of HTTP requests is via pluggable modules and authorization is specified declaratively as docstring annotations on the API methods. This decouples the API function code from the HTTP-related code.
If you really want to use Wigwam send me a message and I can show you some live examples and help you get started. Otherwise, there is a probably out of date example you can look at over here.
Copyright (c) 2012 Micha Niskin
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.