In Laravel 6, execute the command: php artisan telescope:publish, report an error: There are no commands defined in the “teleScope” namespace.
1. In Laravel 6, execute the command: php artisan telescope:publish, report an error: There are no commands defined in the “teleScope” namespace.. as shown in Figure 1
PS E:\wwwroot\object> php artisan telescope:publish
There are no commands defined in the "telescope" namespace.
2. Check composer.json, laravel/teleScope exists in require-dev.
"require-dev": {
"allure-framework/allure-phpunit": "^1.3",
"barryvdh/laravel-debugbar": "^3.6",
"beyondcode/laravel-dump-server": "^1.0",
"beyondcode/laravel-er-diagram-generator": "^1.4",
"brianium/paratest": "^2.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"laravel/telescope": "^2.1",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5",
"squizlabs/php_codesniffer": "^3.5"
},
3. Check the directory /config, the file telescope.php already exists, the file: /app/providers/teleScopeServiceProvider.php already exists. But the directory /public/vendor/teleScope does not exist.
4. Access:https://object.local/telescope, error: RuntimeException
The telescope assets are not published. Please run: php artisan telescope:publish. as shown in Figure 2
5. To view the list of all available Artisan commands, use the list command. There is no telescope in it
6. Check the file /app/providers/appServiceProvider.php, and the service is not manually registered in the register method of AppServiceProvider, the following code exists
// 流水线运行调用artisan命令的时候会进入到此逻辑,如果日常开发需要使用,在开发时候可以屏蔽这个逻辑
if ($this->app->isLocal() && !$this->app->runningInConsole()) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
7. After deleting !$this->app->RunningInConsole(), execute it again: php artisan telescope:publish, the execution is successful. as shown in Figure 3
// 流水线运行调用artisan命令的时候会进入到此逻辑,如果日常开发需要使用,在开发时候可以屏蔽这个逻辑
if ($this->app->isLocal()) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
PS E:\wwwroot\object> php artisan telescope:publish
Publishing complete.
Copied Directory [\vendor\laravel\telescope\public] To [\public\vendor\telescope]
Publishing complete.
8. Visit again:https://object.local/telescope, the response 200.


