【问题标题】:Laravel cannot find "Class 'Zttp\Zttp' not found" but it is installed by composerLaravel 找不到 "Class 'Zttp\Zttp' not found" 但它是由 composer 安装的
【发布时间】:2018-09-20 16:17:37
【问题描述】:

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

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

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

【问题讨论】:

  • 你安装了吗? composer update
  • 是的,并且也在主根目录中运行它

标签: php laravel laravel-nova


【解决方案1】:

查看您的composer.lock 后,我确定您在包裹上使用composer update

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

【讨论】:

  • 做到了。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-08
  • 2015-02-12
  • 2018-09-26
  • 1970-01-01
  • 1970-01-01
  • 2017-11-25
  • 2022-08-14
相关资源
最近更新 更多