Skip to content

Commit

Permalink
Add command (#48751)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorgehman authored Oct 18, 2023
1 parent 2dcc960 commit 2a4c30c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,24 @@ public function runningInConsole()
return $this->isRunningInConsole;
}

/**
* Determine if the application is running any of the given console commands.
*
* @param string|array ...$commands
* @return bool
*/
public function runningConsoleCommand(...$commands)
{
if (! $this->runningInConsole()) {
return false;
}

return in_array(
$_SERVER['argv'][1] ?? null,
is_array($commands[0]) ? $commands[0] : $commands
);
}

/**
* Determine if the application is running unit tests.
*
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Support/Facades/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @method static bool isProduction()
* @method static string detectEnvironment(\Closure $callback)
* @method static bool runningInConsole()
* @method static bool runningConsoleCommand(string|array ...$commands)
* @method static bool runningUnitTests()
* @method static bool hasDebugModeEnabled()
* @method static void registerConfiguredProviders()
Expand Down

0 comments on commit 2a4c30c

Please sign in to comment.