-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[11.x] Add bug
Command
#50952
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
Closed
Closed
[11.x] Add bug
Command
#50952
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7dd51a3
Create BugCommand.php
milwad-dev 09684a2
register bug command
milwad-dev e6ed185
wip
milwad-dev c7600a0
Update BugCommand.php
milwad-dev e848d59
Update BugCommand.php
milwad-dev 13984b0
Update BugCommand.php
milwad-dev 49554d2
Update BugCommand.php
milwad-dev 8065759
Update BugCommand.php
milwad-dev 325d991
stylci
milwad-dev 7e8e0ca
Update BugCommand.php
milwad-dev d2f658d
Merge branch '11.x' of https://github.com/laravel/framework into add-…
milwad-dev 2007b59
Update Bug_report.yml
milwad-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Illuminate\Foundation\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
|
||
#[AsCommand(name: 'bug')] | ||
class BugCommand extends Command | ||
{ | ||
/** | ||
* The console command signature. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'bug'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Start to create a bug report'; | ||
|
||
/** | ||
* The issue url. | ||
* | ||
* @var string | ||
*/ | ||
protected $url = 'https://github.com/laravel/framework/issues/new'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$osCommand = $this->detectOsName(); | ||
$url = $this->getUrl(); | ||
|
||
exec("$osCommand $url"); | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* Detect the OS name and get the current command. | ||
* | ||
* @return string | ||
*/ | ||
protected function detectOsName() | ||
{ | ||
return match (PHP_OS_FAMILY) { | ||
'Windows' => 'start', | ||
'Linux', 'Darwin' => 'xdg-open', | ||
milwad-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'default' => '', | ||
}; | ||
} | ||
|
||
/** | ||
* Get the full url. | ||
* | ||
* @return string | ||
*/ | ||
protected function getUrl() | ||
{ | ||
$dbInfo = config('database.default').'-'.DB::connection()->getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION); | ||
|
||
return implode([$this->url, '?', http_build_query([ | ||
'assignees' => null, | ||
'labels' => null, | ||
'template' => 'Bug_report.yml', | ||
'laravel_version=' => $this->laravel->version(), | ||
'php_version' => phpversion(), | ||
'database_info' => $dbInfo, | ||
])]); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.