From 72bfd8959b1c061dfbbc6a4dd1a7d028b8121229 Mon Sep 17 00:00:00 2001 From: Hasin Hayder Date: Tue, 16 Jun 2026 21:38:11 +0530 Subject: [PATCH] Fix default DevCommands registration Allow Laravel's built-in dev commands to register from registerDefaults() without weakening the vendor guard for public DevCommands registration. --- src/Illuminate/Foundation/DevCommands.php | 5 +++ .../Foundation/FoundationDevCommandsTest.php | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) 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__.'/../..');