Skip to content

Instantly share code, notes, and snippets.

@connordavison
Created December 7, 2015 21:41
Show Gist options
  • Select an option

  • Save connordavison/f8882eb4c84462e01b39 to your computer and use it in GitHub Desktop.

Select an option

Save connordavison/f8882eb4c84462e01b39 to your computer and use it in GitHub Desktop.
PsySH bootstrap for finding the nearest autoloader. Doesn't pollute the global scope.
<?php
call_user_func(function () {
$autoloader = 'vendor/autoload.php';
do {
if (is_readable($autoloader)) {
require_once $autoloader;
echo "Autoloader loaded: $autoloader.\n";
break;
}
$autoloader = '../' . $autoloader;
} while (realpath($autoloader) !== '/');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment