没有不值得去解决的问题,也没有不值得去学习的技术!

Error When Running php artisan telescope:install in Laravel 9: There Are No Commands Defined in the “telescope” Namespace

In Laravel 9, running php artisan telescope:install throws an error: ERROR There are no commands defined in the "telescope" namespace.

1. In Laravel 9, running `php artisan telescope:install` throws an error: ERROR There are no commands defined in the “telescope” namespace. See Figure 1.

In Laravel 9, running php artisan telescope:install throws an error: ERROR There are no commands defined in the "telescope" namespace.
Figure 1
Plaintext

PS E:\wwwroot\erp-backend> php artisan telescope:install

   ERROR  There are no commands defined in the "telescope" namespace.


2. I found that the TelescopeServiceProvider service provider registration had been removed from the application’s config/app.php configuration file. I added it back first. See Figure 2.

Found that the TelescopeServiceProvider service provider registration had been removed from the application's config/app.php configuration file. Added it back first
Figure 2

3. Run `php artisan telescope:install` again. No more errors. See Figure 3.

Run php artisan telescope:install again. No more errors
Figure 3
Plaintext

PS E:\wwwroot\erp-backend> php artisan telescope:install
Publishing Telescope Service Provider...
Publishing Telescope Assets...
Publishing Telescope Configuration...
Telescope scaffolding installed successfully.

4. Revert the operation from step 2, and manually register the Telescope service provider in the register method of the App\Providers\AppServiceProvider class.

PHP

/**
 * 注册应用服务
 *
 * @return void
 */
public function register()
{
    if ($this->app->environment('local')) {
        $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
        $this->app->register(TelescopeServiceProvider::class);
    }
}

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系