我正在使用一个名为 Pheanstalk 的作曲家下载的库。我正在运行以下脚本:
<?php
//... some unrelated code
require_once('vendor/autoload.php'); //loading the autoload file from composer
use Pheanstalk\Pheanstalk; //using the namespace
$pheanstalk = new Pheanstalk('127.0.0.1'); //initiating an object
//... some unrelated code
?>
出现以下错误:
Fatal Error: Class 'Pheanstalk\Pheanstalk' not found in /opt/lampp/htdocs/project_zero/index.php on line 16
第 16 行是:$pheanstalk = new Pheanstalk('127.0.0.1');
问题:为什么我会收到此错误?上面的脚本基本上是从Pheanstalk github 页面上给出的用法示例中复制而来的: https ://github.com/pda/pheanstalk 。
我的composer.json
文件内容是:
{
"require": {
"pda/pheanstalk": "2.1.1"
}
}
编辑:
使用时的新错误:
use \Pheanstalk_Pheanstalk
错误:
Warning: The use statement with non-compound name 'Pheanstalk_Pheanstalk' has no effect in /opt/lampp/htdocs/project_zero/index.php on line 14
Fatal error: Class 'Pheanstalk' not found in /opt/lampp/htdocs/project_zero/index.php on line 17