dtpwra8456 2019-05-03 15:44
浏览 285

Laravel nova工具无法使用Class not found错误

I'm creating a tool with laravel nova.

I ran this command first,

php artisan nova:tool mytools/cachier

And then in my mai app directory App\Providers\NovaServiceProvider I added,

use Mytools\Cachier\Cachier;

public function tools()
    {
        return [
            new Cachier(),
        ];

    }

This is my tool composer json

{
    "name": "mytools/cachier",
    "description": "A Laravel Nova tool.",
    "keywords": [
        "laravel",
        "nova"
    ],
    "license": "MIT",
    "require": {
        "php": ">=7.1.0"
    },
    "autoload": {
        "psr-4": {
            "Mytools\\Cachier\\": "src/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Mytools\\Cachier\\ToolServiceProvider"
            ]
        }
    },
    "config": {
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

But now when I'm trying to access app I'm getting this error.

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Mytools\Cachier\Cachier' not found

It would be great if someone can help :'(

  • 写回答

2条回答 默认 最新

  • douying1119 2019-05-03 16:15
    关注

    Check the namespace that you imported:

    use Mytools\Cachier\Cachier; // <----
    
    public function tools()
        {
            return [
                new Cachier(),
            ];
    
        }
    

    I think it should be:

    use Mytools\Cachier; // <----
    
    // ...
    

    PS: Also, check the namespace defined inside your class to match this one.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line