Skip to content

[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
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@ body:
attributes:
value: "Please read [our full contribution guide](https://laravel.com/docs/contributions#bug-reports) before submitting bug reports. If you notice improper DocBlock, PHPStan, or IDE warnings while using Laravel, do not create a GitHub issue. Instead, please submit a pull request to fix the problem."
- type: input
id: laravel_version
attributes:
label: Laravel Version
description: Provide the Laravel version that you are using. [Please ensure it is still supported.](https://laravel.com/docs/releases#support-policy)
placeholder: 10.4.1
validations:
required: true
- type: input
id: php_version
attributes:
label: PHP Version
description: Provide the PHP version that you are using.
placeholder: 8.1.4
validations:
required: true
- type: input
id: database_info
attributes:
label: Database Driver & Version
description: If applicable, provide the database driver and version you are using.
placeholder: "MySQL 8.0.31 for macOS 13.0 on arm64 (Homebrew)"
validations:
required: false
- type: textarea
id: description
attributes:
label: Description
description: Provide a detailed description of the issue you are facing.
Expand All @@ -37,4 +41,4 @@ body:
description: Provide detailed steps to reproduce your issue. If necessary, please provide a GitHub repository to demonstrate your issue using `laravel new bug-report --github="--public"`.
validations:
required: true

80 changes: 80 additions & 0 deletions src/Illuminate/Foundation/Console/BugCommand.php
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',
'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,
])]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Foundation\Console\ApiInstallCommand;
use Illuminate\Foundation\Console\BroadcastingInstallCommand;
use Illuminate\Foundation\Console\BugCommand;
use Illuminate\Foundation\Console\CastMakeCommand;
use Illuminate\Foundation\Console\ChannelListCommand;
use Illuminate\Foundation\Console\ChannelMakeCommand;
Expand Down Expand Up @@ -115,6 +116,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
*/
protected $commands = [
'About' => AboutCommand::class,
'Bug' => BugCommand::class,
'CacheClear' => CacheClearCommand::class,
'CacheForget' => CacheForgetCommand::class,
'ClearCompiled' => ClearCompiledCommand::class,
Expand Down