【问题标题】:Can not get access to Telescope dashboard无法访问望远镜仪表板
【发布时间】:2021-09-28 12:25:15
【问题描述】:

我想将望远镜添加到我的 laravel 8 应用程序中,但在 .env 中

APP_ENV=local
TELESCOPE_ENABLED=true

并在现场阅读:

https://laravel.com/docs/8.x/telescope
The Telescope dashboard may be accessed at the /telescope route. By default, you will only be able to access this dashboard in the local environment. 

在网址上

http://local-tads.com/telescope

我收到 404 错误,其中 http://local-tads.com - 是我的应用程序的本地托管

在 app/Providers/AppServiceProvider.php 文件中我添加了几行:

<?php

namespace App\Providers;


class AppServiceProvider extends ServiceProvider
...
        if ($this->app->environment('local')) {

            $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);


            \Event::listen(
                [
                    TransactionBeginning::class,
                ],
                function ($event) {
                   ...

我有未修改的 vendor/laravel/telescope/config/telescope.php 文件。 我是否需要在 routes/web.php 中添加路由以及以哪种方式添加?

如何访问望远镜仪表板?

更新块: 我运行这两个命令:

php artisan telescope:install

php artisan migrate

但是我没有找到config/telescope.php,所以我从/vendor/子目录复制了它

运行命令

php artisan route:list 

没有任何“望远镜”条目。

在 app/Providers/AppServiceProvider.php 文件中,我用望远镜添加了几行:

<?php

namespace App\Providers;

use App\Library\Services\AdminCategoryCrud;
//use App\Providers\TelescopeServiceProvider;
use Illuminate\Database\Events\TransactionBeginning;
use Illuminate\Database\Events\TransactionCommitted;
use Illuminate\Database\Events\TransactionRolledBack;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;

use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        if ($this->app->environment('local')) {
            $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
            $this->app->register(TelescopeServiceProvider::class);
        }

不确定是否一切正确? 在环境中我有:

APP_ENV=local
TELESCOPE_ENABLED=true

在 composer.json 我添加了一行:

    "extra": {
        "laravel": {
            "dont-discover": [
                "laravel/telescope"
            ]
        }
    },

和更新的作曲家

但是http://local-tads.com/telescope - 仍然引发 404 错误...

提前致谢!

【问题讨论】:

  • 请看更新块

标签: laravel laravel-telescope


【解决方案1】:

您的问题的一个潜在答案可能是从dont-discover 阵列中删除望远镜包。所以你的新extra 部分会是这样的:

"extra": {
    "laravel": {
        "dont-discover": []
    }
}

另外,不要忘记通过在项目文件夹中运行 composer dump-autoload 来转储自动加载。我希望这对你有帮助:D

更多信息请查看this issue on the github repository

【讨论】:

    猜你喜欢
    • 2016-12-08
    • 2018-08-25
    • 2016-03-27
    • 2017-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多