Laravel找不到“找不到类'Zttp \ Zttp'”,但是它是由作曲家安装的

时间:2018-09-20 16:17:38

标签: php laravel laravel-nova

我正在为Laravel Nova创建卡片。

我创建了一个简单的API路由,该路由将调用端点并返回响应。

api.php

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Zttp\Zttp;

/*
|--------------------------------------------------------------------------
| Card API Routes
|--------------------------------------------------------------------------
|
| Here is where you may register API routes for your card. These routes
| are loaded by the ServiceProvider of your card. You're free to add
| as many additional routes to this file as your card may require.
|
*/

 Route::get('/endpoint', function (Request $request) {
     $response = Zttp::get('https://novapackages.com/api/recent');
        return $response->json()['data'];
 });

但是当我沿着那条路线走时,我得到了错误:

  

找不到类'Zttp \ Zttp'

这是我的composer.json的样子:

{
    "name": "jachno/test-http-card",
    "description": "A Laravel Nova card.",
    "keywords": [
        "laravel",
        "nova"
    ],
    "license": "MIT",
    "require": {
        "php": ">=7.1.0",
        "kitetail/zttp": "^0.3.0"
    },
    "autoload": {
        "psr-4": {
            "Jachno\\TestHttpCard\\": "src/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Jachno\\TestHttpCard\\CardServiceProvider"
            ]
        }
    },
    "config": {
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

这一定是显而易见的,我基于此存储库正在做的事

https://github.com/tightenco/nova-package-discovery

这几乎完全在执行我的操作。我说的几乎是一定有区别,但我找不到。

我还发布了a complete repo,包括供应商目录等。

1 个答案:

答案 0 :(得分:0)

查看composer.lock后,我确定您正在对包裹进行composer update

尝试从您的Laravel项目而不是您的软件包中composer update