首页 > 解决方案 > 从作曲家包中找不到php类

问题描述

我安装了这个包composer require konekt/pdf-invoice,但标准use在调用它时找不到该类。

然后在我的脚本中我正在使用:

<?php
include "includes/basics.php" ;
use Konekt\PdfInvoice\InvoicePrinter;


function genPDF($id) {
  $invoice = new InvoicePrinter();
  ...
  ...
}
?>

并产生错误:
PHP Fatal Error: Uncaught Error: Class 'Konekt\PdfInvoice\InvoicePrinter' not found in wBilling.php:511

在我的/home/userID/php/vendor/konekt/pdf-invoice存在中,据我所知,composer.json 文件已正确定义

{
    "name": "konekt/pdf-invoice",
    "description": "Library to generate PDF invoices",
    "type": "library",
    "license": "GPL-2.0-or-later",
    "keywords": ["invoice", "pdf", "konekt", "artkonekt"],
    "support": {
        "source": "https://github.com/artkonekt/pdf-invoice"
    },
    "authors": [
        {
            "name": "Attila Fulop",
            "homepage": "https://github.com/fulopattila122"
        }
    ],
    "require": {
        "php": ">=5.6",
        "ext-iconv": "*",
        "ext-mbstring": "*",
        "setasign/fpdf": "~1.8.1"
    },
    "require-dev": {
        "phpunit/phpunit": "~5.0"
    },
    "autoload": {
        "psr-4": { "Konekt\\PdfInvoice\\": "src/" }
    },
    "autoload-dev": {
        "psr-4": {
            "Konekt\\PdfInvoice\\Tests\\": "tests/"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.5-dev"
        }
    }
}

标签: phpclassnamespacesrequire

解决方案


推荐阅读