Skip to content

Commit

Permalink
Made autoloader work within Phar files
Browse files Browse the repository at this point in the history
realpath() has issues when executing inside of a Phar.
I also simplified the autoloader code.
  • Loading branch information
travispaul committed Aug 21, 2014
1 parent 565df4b commit 1e056bb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Phpass/Loader.php
Expand Up @@ -46,16 +46,11 @@ class Loader
*/
public static function load($class)
{
if (substr($class, 0, 6) !== 'Phpass') {
return;
}
if (stripos($class, 'Phpass') === 0) {
$file = str_replace('\\', '/', $class);

$libraryRoot = realpath(__DIR__ . '/../');
$file = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
$file = realpath($libraryRoot . DIRECTORY_SEPARATOR . $file);
if (substr($file, 0, strlen($libraryRoot)) == $libraryRoot) {
if (is_readable($file)) {
include $file;
if (file_exists(dirname(__FILE__) . '/../' . $file . '.php')) {
require_once(dirname(__FILE__) . '/../' . $file . '.php');
}
}
}
Expand Down

0 comments on commit 1e056bb

Please sign in to comment.