Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoloader.php detection with $_composer_autoload_path #18

Open
Sweetchuck opened this issue Apr 6, 2023 · 1 comment · May be fixed by #24
Open

autoloader.php detection with $_composer_autoload_path #18

Sweetchuck opened this issue Apr 6, 2023 · 1 comment · May be fixed by #24

Comments

@Sweetchuck
Copy link

Composer 2.2 released 2021-12-22
$_composer_autoload_path


proposed solution

./composer-diff.php

$cwd = isset($_SERVER['PWD']) && is_dir($_SERVER['PWD']) ? $_SERVER['PWD'] : getcwd();
// See https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
if ((isset($_composer_autoload_path) && file_exists($autoloadFile = $_composer_autoload_path))
    || file_exists($autoloadFile = __DIR__ . '/../../autoload.php')
    || file_exists($autoloadFile = __DIR__ . '/../autoload.php')
    || file_exists($autoloadFile = __DIR__ . '/vendor/autoload.php')
) {
    \define('JBZOO_AUTOLOAD_FILE', $autoloadFile);
} else {
    throw new \Exception("Could not locate autoload.php. cwd is $cwd; __DIR__ is " . __DIR__);
}

require_once JBZOO_AUTOLOAD_FILE;
@SmetDenis
Copy link
Member

Hi @Sweetchuck
Thank you for your idea.

Actually, I didn't know about the $_composer_autoload_path.
I'll definitely explore the questions these days.

@SmetDenis SmetDenis linked a pull request Jul 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants