【发布时间】:2018-06-29 23:35:45
【问题描述】:
我有一个 config.php 文件,我在其中为我的所有个人课程使用自动加载
function __autoload($class_name) {
include __DIR__.'/classes/'.$class_name . '.php';
}
我现在需要使用来自作曲家的第 3 方课程,该课程位于
/vendor/guzzlehttp.
所以我现在的代码是:
require('Config.php'); // my config file: this is used in ALL site
require 'vendor/autoload.php'; // the copmoser
$client = new GuzzleHttp\Client([]); // call to the 3rd party class installed by composer
引发 404 错误:php 在 /classes 中搜索 GuzzleHttp
未捕获的错误:找不到类“GuzzleHttp\Client”
我不知道如何解决这个问题:我需要在 /classes 中保留自己的课程
我需要自动加载它们,因为所有网站都使用它。
那么:如何在我的网站上使用 composer 安装的类?
我的 composer.json 内容是:
{
"require": {
"firebase/php-jwt": "^5.0"
}
}
【问题讨论】:
标签: php composer-php