Permalink
Browse files

Initial commit for new public phpsh repo.

This also marks the release of phpsh 1.1.

Reviewed By: ccheever

Test Plan: Installing, running test/'s.  Has also been deployed at fb
for a week or so.

Revert Plan: ok
  • Loading branch information...
0 parents commit 9317b56fd47fc702109a6b3e6a5765ae1c109aac Daniel Corson committed Oct 13, 2008
Showing with 1,875 additions and 0 deletions.
  1. +10 −0 LICENSE
  2. +44 −0 README
  3. +40 −0 phpshrc.example.php
  4. +20 −0 setup.py
  5. +576 −0 src/__init__.py
  6. +25 −0 src/ansicolor.py
  7. +141 −0 src/cmd_util.py
  8. +87 −0 src/ctags.py
  9. +425 −0 src/html2text.py
  10. +85 −0 src/manual.py
  11. BIN src/php_manual.db
  12. +148 −0 src/phpsh
  13. +210 −0 src/phpsh.php
  14. +1 −0 src/phpsh.py
  15. +4 −0 src/phpsh_check_syntax
  16. +38 −0 src/phpshrc.php
  17. +6 −0 test/all_good.pht
  18. +15 −0 test/err_and_multiout.pht
10 LICENSE
@@ -0,0 +1,10 @@
+Copyright (c) 2006, Dan Corson, Charles Cheever, Facebook, inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of Facebook, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 README
@@ -0,0 +1,44 @@
+To install:
+~ python setup.py build
+~ sudo python setup.py install
+(Will download and install the pysqlite dependency for you if needed.)
+
+The buildscript uses setuptools. This comes with python >= 2.5.
+If you are using older python, go grab EasyInstall:
+http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install
+
+To set up after install:
+- If you just want to use vanilla php, just do ~ phpsh and have fun.
+- To connect to an actual codebase, e.g.:
+ ~ cd ~/www
+ ~ ctags -R # for phpsh ctags integration, recommended
+ ~ phpsh lib/init.php # or some file(s) that load codebase libraries
+- To get autoloading, modify /etc/phpsh/phpshrc.php. After that it's just:
+ ~ cd ~/www
+ ~ phpsh
+ And for times when you just want vanilla php:
+ ~ phpsh -c none
+- For individual configuration, also see phpshrc.example.php in the php
+ distribution.
+
+Contact phpsh@facebook.com with any questions.
+
+
+Note to ppl hacking on phpsh:
+- For faster iteration, after installing once, you can run phpsh from src/
+directly without reinstalling. E.g.:
+ ~ cd ~/www
+ ~ ~/projects/phpsh/src/phpsh
+
+Todo for after phpsh 1.1
+- Simple phpsh breakpoints that you can insert into your php code.
+- Maybe phpsh_check_syntax shouldn't actually be installed as a script, and
+ just be a pkg_resource? Didn't want to worry about zip file overhead, and
+ installing didn't seem like a big deal.
+- Similarly, php_manual.db should probably go in share/ not etc/ but similarly
+ was worried about b.s. with setuptools..
+- Paging for long php> d .. results? Or is terminal scroll fine..
+- Thread loading ctags and starting php? Would speed start but not restart.
+- Command-line apc for faster php startup for large codebases.
+- Note on php start error to start from codebase place?
+- Make tab to show function signature work with multiline func sigs.
@@ -0,0 +1,40 @@
+<?php
+# copy this to ~/.phpshrc.php
+
+# load any system defaults / codebase-modes
+require_once '/etc/phpsh/phpshrc.php';
+
+# the examples here are some functions i use for easy io with the outside world
+
+define('DEFAULT_IO_FILE', getenv('HOME').'/o');
+
+/**
+ * append array or var to ~/o
+ * @author dcorson
+ */
+function o($x, $fn = DEFAULT_IO_FILE) {
+ $f = fopen($fn, 'a');
+ if (is_array($x)) {
+ fwrite($f, implode("\n", $x)."\n");
+ } else {
+ fwrite($f, $x."\n");
+ }
+ fclose($f);
+ return true;
+}
+
+/**
+ * strip last char (typically used to kill "\n") from line
+ * @author dcorson
+ */
+function _rstrip($l) {
+ return substr($l, 0, strlen($l) - 1);
+}
+
+/**
+ * read array from ~/o
+ * @author dcorson
+ */
+function i($fn = DEFAULT_IO_FILE) {
+ return array_map('_rstrip', file($fn));
+}
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+from setuptools import setup
+
+setup(
+ name='phpsh',
+ version='1.1',
+ description='interactive shell into a php codebase',
+ author='facebook',
+ author_email='phpsh@facebook.com',
+ url='http://www.phpsh.org/',
+ packages=['phpsh'],
+ package_dir={'phpsh': 'src'},
+ package_data={'phpsh': ['*.php']},
+ scripts=['src/phpsh', 'src/phpsh_check_syntax'],
+ data_files=[
+ ('/etc/phpsh', ['src/phpshrc.php']),
+ ('/etc/phpsh', ['src/php_manual.db']),
+ ],
+ install_requires=['pysqlite'],
+)
Oops, something went wrong.

0 comments on commit 9317b56

Please sign in to comment.