diff --git a/src/Illuminate/Foundation/DevCommands.php b/src/Illuminate/Foundation/DevCommands.php index 2a4c35ab025e..3f674150764a 100644 --- a/src/Illuminate/Foundation/DevCommands.php +++ b/src/Illuminate/Foundation/DevCommands.php @@ -186,6 +186,11 @@ protected static function preventVendorRegistration(string $name) foreach ($trace as $frame) { $file = $frame['file'] ?? null; $class = $frame['class'] ?? null; + $function = $frame['function'] ?? null; + + if ($class === self::class && $function === 'registerDefaults') { + return; + } if ($class === self::class) { continue; diff --git a/tests/Foundation/FoundationDevCommandsTest.php b/tests/Foundation/FoundationDevCommandsTest.php index 6fd10cdd96f4..a991db41ff1f 100644 --- a/tests/Foundation/FoundationDevCommandsTest.php +++ b/tests/Foundation/FoundationDevCommandsTest.php @@ -204,6 +204,37 @@ public function testRegisterDefaultsRegistersExpectedCommands() $this->assertContains('vite', $names); } + public function testRegisterDefaultsCanBeCalledFromVendorPath() + { + $basePath = realpath(__DIR__.'/../..'); + $vendorFile = $basePath.'/vendor/_test_register_defaults_'.uniqid().'.php'; + + file_put_contents($vendorFile, <<<'PHP' +run(); + + $this->assertSame('server,queue,logs,vite', $process->getOutput()); + } finally { + unlink($vendorFile); + } + } + public function testVendorRegistrationIsPrevented() { $basePath = realpath(__DIR__.'/../..');