致命错误:未捕获错误:找不到类'Foolz \ SphinxQL \ Connection'

问题描述 投票:0回答:1

我使用以下json文件为作曲家安装了Foolz SphinxQL Query Builder for PHP:

{
    "require": {
        "foolz/sphinxql-query-builder": "^2.0"
    }
}

我的php如下:

<?php
require_once __DIR__ . '/vendor/autoload.php';

use Foolz\SphinxQL\SphinxQL;
use Foolz\SphinxQL\Connection;

error_reporting(E_ALL);
ini_set('display_errors', 1);

// create a SphinxQL Connection object to use with SphinxQL
$conn = new Connection();
$conn->setConnectionParams('127.0.0.1', 9306);

$query = SphinxQL::create($conn)->select('*')
    ->from('test1')
    ->match('@test document');
#    ->where('banned', '=', 1);

$result = $query->execute();

var_dump($result);

?>

使用我的调试器,我看到自动加载器(函数findFileWithExtension)正试图在/mnt/i/var/www/vhosts/my.play.net/sphinx/vendor/composer/../foolz/sphinxql-query-builder/Connection.php找到该文件,当它应该在/mnt/i/var/www/vhosts/my.play.net/sphinx/vendor/composer/../foolz/sphinxql-query-builder/Drivers/Mysqli/Connection.php中查找它实际所在的位置时。

任何人都可以建议我为什么会看到这个以及我如何解决它?

php composer-php autoloader sphinxql
1个回答
1
投票

您使用的名称空间不正确。要获得vendor/foolz/sphinxql-query-builder/src/Drivers/Mysqli/Connection.php,您需要使用Foolz\SphinxQL\Drivers\Mysqli\Connection作为FQN:

use Foolz\SphinxQL\SphinxQL;
use Foolz\SphinxQL\Drivers\Mysqli\Connection;
© www.soinside.com 2019 - 2024. All rights reserved.