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

If Drupal cannot be detected, fallback to using Composer to detect the installed path #635

Open
mglaman opened this issue Nov 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mglaman
Copy link
Owner

mglaman commented Nov 11, 2023

Feature request

Various hacks are needed if drupal/core is in the vendor directory. The drupal-finder package doesn't support this (and probably shouldn't.) But we can in the autoloader: https://github.com/mglaman/phpstan-drupal/blob/main/src/Drupal/DrupalAutoloader.php#L60-L69

        $drupalRoot = $finder->getDrupalRoot();
        $drupalVendorRoot = $finder->getVendorDir();
        if (! (bool) $drupalRoot || ! (bool) $drupalVendorRoot) {
            throw new \RuntimeException("Unable to detect Drupal at {$drupalParams['drupal_root']}");
        }

Instead of throwing a runtime exception here, try using Composer's installed paths to find drupal/core:

\Composer\InstalledVersions::getInstallPath('drupal/core')

Then less hacks are needed.

@mglaman mglaman added the enhancement New feature or request label Nov 11, 2023
@mglaman
Copy link
Owner Author

mglaman commented Nov 13, 2023

See webflo/drupal-finder#64

@AlexSkrypnyk
Copy link

I've added a PR to provide a temp workaround
#702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants