laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.32k stars 130 forks source link

Fix: Correct vendor directory path resolution for Laravel Artisan Tin… #179

Closed jubayed closed 3 months ago

jubayed commented 3 months ago

Overview

This pull request addresses an issue with the Laravel Artisan Tinker command where the vendor directory path might not be correctly determined when developers customize the vendor directory. This fix ensures flexibility in determining the vendor directory path while resolving issues with running the Laravel Artisan Tinker command in various environments.

Changes

Detailed Changes

use Composer\InstalledVersions;
$vendorDir = $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor';
if (!is_dir($vendorDir)) {
    $vendorDir = realpath(InstalledVersions::getRootPackage()['install_path']) . DIRECTORY_SEPARATOR . 'vendor';
}

$path = Env::get('COMPOSER_VENDOR_DIR', $vendorDir);

Testing

Verified that the php artisan tinker command works correctly with and without the COMPOSER_VENDOR_DIR environment variable set. Ensured that the fallback to InstalledVersions::getRootPackage() is correctly handled when the vendor directory does not exist.

Impact

This fix ensures that developers have the flexibility to customize the vendor directory path while maintaining the stability of the Laravel Artisan Tinker command in various deployment environments.

Please review the changes and provide feedback. This revision emphasizes the importance of flexibility in determining the vendor directory path, accommodating developers who may customize this directory according to their needs.

taylorotwell commented 3 months ago

I am closing this pull request because it lacks sufficient explanation, tests, or both. It is difficult for us to merge pull requests without these things because the change may introduce breaking changes to the framework.

Feel free to re-submit your change with a thorough explanation of the feature and tests - integration tests are preferred over unit tests. Please include it's benefit to end users; the reasons it does not break any existing features; how it makes building web applications easier, etc.

Thanks!