* This file is part of Psy Shell.
* (c) 2012-2017 Justin Hileman
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
// Try to find an autoloader for a local psysh version.
// We'll wrap this whole mess in a Closure so it doesn't leak any globals.
call_user_func(function () {
// Find the cwd arg (if present)
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
foreach ($argv as $i => $arg) {
if ($i >= count($argv) - 1) {
echo 'Missing --cwd argument.' . PHP_EOL;
if (preg_match('/^--cwd=/', $arg)) {
// Or fall back to the actual cwd
$cwd = str_replace('\\', '/', $cwd);
$chunks = explode('/', $cwd);