Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
fix(autoloader): check for Roots\Soil namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Jul 27, 2021
1 parent 83a8378 commit b136742
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/autoload.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

namespace Roots\Soil;

require_once __DIR__ . '/helpers.php';

spl_autoload_register(function ($className) {
if (strpos($className, __NAMESPACE__) !== 0) {
return;
}
$relativeClassName = array_slice(explode('\\', $className), 2);
$file = __DIR__ . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $relativeClassName) . '.php';
if (file_exists($file)) {
require $file;
return true;
require_once $file;
}
return false;
});

0 comments on commit b136742

Please sign in to comment.