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

Fix: Correct vendor directory path resolution for Laravel Artisan Tinker command #178

Closed
wants to merge 2 commits into from

Conversation

hmjubayed
Copy link

Overview

This pull request addresses an issue with the Laravel Artisan Tinker command where the vendor directory path might not be correctly determined. This fix ensures that the correct vendor directory is used, resolving issues with running the Laravel Artisan Tinker command in various environments.

Changes

  • Updated the code to use Env::get to retrieve the COMPOSER_VENDOR_DIR environment variable, defaulting to the standard vendor directory path if not set.
  • Added a check to ensure the determined vendor directory is valid.
  • If the vendor directory is not valid, it falls back to using the path obtained from InstalledVersions::getRootPackage().
  • Constructed the path to autoload_classmap.php based on the resolved vendor directory.

Detailed Changes

use use Composer\InstalledVersions;
$vendorDir = Env::get('COMPOSER_VENDOR_DIR', $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor');

if (!is_dir($vendorDir)) {
    $vendorDir = realpath(InstalledVersions::getRootPackage()['install_path'] . '/vendor');
}

$path = $vendorDir . '/composer/autoload_classmap.php';

Impact

This fix will ensure the Laravel Artisan Tinker command functions correctly in various deployment environments, particularly where the vendor directory might be customized or not present by default.

Fix: Resolve vendor directory path for artisan tinker

This commit resolves an issue with the PHP Artisan Tinker command where the vendor directory path might not be correctly determined. 

Changes:
- Modified the code to use `Env::get` for retrieving the `COMPOSER_VENDOR_DIR` environment variable, falling back to the default vendor directory path.
- Added a check to see if the determined vendor directory is valid.
- If the vendor directory is not valid, it falls back to using the path obtained from `InstalledVersions::getRootPackage()`.
- Ensured that the path to `autoload_classmap.php` is constructed correctly based on the resolved vendor directory.

This fix ensures that the correct vendor directory is used, thereby resolving issues with running PHP Artisan Tinker in various environments.
Fix: Correct vendor directory path resolution for Laravel Artisan Tinker

This commit addresses an issue with the Laravel Artisan Tinker command where the vendor directory path might not be correctly determined.

Changes:
- Updated the code to use `Env::get` to retrieve the `COMPOSER_VENDOR_DIR` environment variable, defaulting to the standard vendor directory path if not set.
- Added a check to ensure the determined vendor directory is valid.
- If the vendor directory is not valid, it falls back to using the path obtained from `InstalledVersions::getRootPackage()`.
- Constructed the path to `autoload_classmap.php` based on the resolved vendor directory.

This fix ensures that the correct vendor directory is used, resolving issues with running the Laravel Artisan Tinker command in various environments.
@hmjubayed hmjubayed closed this by deleting the head repository Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant