Last active
January 18, 2017 19:56
-
-
Save noahduncan/bcb50a48fbea4d0067079b3cce67cc76 to your computer and use it in GitHub Desktop.
Autoload Interactive PHP Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias iphp="php -d auto_prepend_file=~/.phpinitscript.php -a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file lives in my home directory. | |
*/ | |
$projects_root = "/home/noah/projects"; | |
$dircount = count(explode('/', $projects_root)); | |
$curpath = trim(`pwd`); | |
if (false === strpos($projects_root, $curpath)) { | |
die('Not in a project directory.'); | |
} | |
$dirs = explode('/', $curpath); | |
// /home/noah/projects/<project> | |
$project = $dirs[$dircount]; | |
$proj_root = implode('/', array_slice($dirs,0,$dircount+1)); | |
switch ($project) { | |
case 'eminutes': | |
$bootstrap_file = '/inc/bootstrap.php'; | |
break; | |
case 'sketchup': | |
$bootstrap_file = '/lib/app.php'; | |
break; | |
default: | |
die('Unknown project ' . $project); | |
break; | |
} | |
$err = fopen('php://stderr','w'); | |
fwrite($err, "Loaded bootstrap file '$proj_root$bootstrap_file'.\n"); | |
fclose($err); | |
require_once $proj_root . $bootstrap_file; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment