1

我正在为 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
}

这一定很明显,我的工作基于这个 repo

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

这几乎就是我正在做的事情。我说几乎因为肯定有一些区别,但我找不到。

我还发布了一个完整的回购,包括供应商目录等。

4

1 回答 1

0

查看您的 后composer.lock,我确定您正在composer update处理您的包裹。

尝试composer update从您的 Laravel 项目中,而不是从您的包中。

于 2018-09-23T20:08:03.780 回答