Work in progress - preloader
This commit is contained in:
parent
fe955ac9fb
commit
a25a827740
|
@ -16,43 +16,15 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
|
|||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
}
|
||||
|
||||
//require_once 'init.php';
|
||||
|
||||
// require_once __DIR__ . '/config/collections.php';
|
||||
// require_once __DIR__ . '/config/currencies.php';
|
||||
// require_once __DIR__ . '/config/eu.php';
|
||||
// require_once __DIR__ . '/config/locales.php';
|
||||
// require_once __DIR__ . '/config/phones.php';
|
||||
// require_once __DIR__ . '/config/platforms.php';
|
||||
// require_once __DIR__ . '/config/providers.php';
|
||||
// require_once __DIR__ . '/config/roles.php';
|
||||
// require_once __DIR__ . '/config/scopes.php';
|
||||
// require_once __DIR__ . '/config/services.php';
|
||||
|
||||
// require_once __DIR__ . '/controllers/web/console.php';
|
||||
// require_once __DIR__ . '/controllers/web/home.php';
|
||||
// require_once __DIR__ . '/controllers/api/account.php';
|
||||
// require_once __DIR__ . '/controllers/api/avatars.php';
|
||||
// require_once __DIR__ . '/controllers/api/database.php';
|
||||
// require_once __DIR__ . '/controllers/api/graphql.php';
|
||||
// require_once __DIR__ . '/controllers/api/health.php';
|
||||
// require_once __DIR__ . '/controllers/api/locale.php';
|
||||
// require_once __DIR__ . '/controllers/api/projects.php';
|
||||
// require_once __DIR__ . '/controllers/api/storage.php';
|
||||
// require_once __DIR__ . '/controllers/api/teams.php';
|
||||
// require_once __DIR__ . '/controllers/api/users.php';
|
||||
|
||||
use Appwrite\Preloader\Preloader;
|
||||
|
||||
require_once __DIR__.'/../app/init.php';
|
||||
require_once __DIR__.'/../app/app.php';
|
||||
|
||||
(new Preloader())
|
||||
->paths(realpath(__DIR__ . '/../vendor/utopia-php'))
|
||||
->paths(realpath(__DIR__ . '/../vendor/appwrite'))
|
||||
//->paths(realpath(__DIR__ . '/config'))
|
||||
// ->ignore(
|
||||
// \Illuminate\Filesystem\Cache::class,
|
||||
// \Illuminate\Log\LogManager::class,
|
||||
// \Illuminate\Http\Testing\File::class,
|
||||
// \Illuminate\Http\UploadedFile::class,
|
||||
// \Illuminate\Support\Carbon::class,
|
||||
// )
|
||||
->paths(realpath(__DIR__ . '/../vendor'))
|
||||
->paths(realpath(__DIR__ . '/../app/config'))
|
||||
->paths(realpath(__DIR__ . '/../app/controllers'))
|
||||
->paths(realpath(__DIR__ . '/../app/views'))
|
||||
->ignore(__DIR__ . '/../vendor/phpmailer/phpmailer/get_oauth_token.php')
|
||||
->load();
|
|
@ -95,28 +95,44 @@ class Preloader
|
|||
private function loadFile(string $path): void
|
||||
{
|
||||
// We resolve the classname from composer's autoload mapping
|
||||
$class = $this->fileMap[$path] ?? null;
|
||||
$class = $this->fileMap[$path] ?? $path;
|
||||
|
||||
// And use it to make sure the class shouldn't be ignored
|
||||
if ($this->shouldIgnore($class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo "[Preloader] Preloaded `{$class}`" . PHP_EOL;
|
||||
// Finally we require the path,
|
||||
// causing all its dependencies to be loaded as well
|
||||
require_once($path);
|
||||
try {
|
||||
ob_start(); //Start of build
|
||||
|
||||
require_once $path;
|
||||
|
||||
$output = mb_strlen(ob_get_contents());
|
||||
|
||||
ob_end_clean(); //End of build
|
||||
} catch (\Throwable $th) {
|
||||
echo "[Preloader] Failed to load `{$class}`" . PHP_EOL;
|
||||
return;
|
||||
}
|
||||
|
||||
self::$count++;
|
||||
|
||||
echo "[Preloader] Preloaded `{$class}`" . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
private function shouldIgnore(?string $name): bool
|
||||
{
|
||||
if ($name === null) {
|
||||
if($name === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!in_array(pathinfo($name, PATHINFO_EXTENSION), ['php'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var_dump($name);
|
||||
foreach ($this->ignores as $ignore) {
|
||||
if (strpos($name, $ignore) === 0) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue