PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 17, 2022

[FIXED] Fatal error: Uncaught Error: Class 'Foolz\SphinxQL\Connection' not found

 January 17, 2022     autoloader, composer-php, php, sphinxql     No comments   

Issue

I installed Foolz SphinxQL Query Builder for PHP with composer using the following json file:

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

My php is as follows:

<?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);

?>

Using my debugger I see the autoloader (function findFileWithExtension) is trying to find the file at /mnt/i/var/www/vhosts/my.play.net/sphinx/vendor/composer/../foolz/sphinxql-query-builder/Connection.php when it should presumably be looking in /mnt/i/var/www/vhosts/my.play.net/sphinx/vendor/composer/../foolz/sphinxql-query-builder/Drivers/Mysqli/Connection.php where it is actually located.

Can anyone advise why I might be seeing this and how I fix it?


Solution

You're using incorrect namespace. To get vendor/foolz/sphinxql-query-builder/src/Drivers/Mysqli/Connection.php you need to use Foolz\SphinxQL\Drivers\Mysqli\Connection as FQN:

use Foolz\SphinxQL\SphinxQL;
use Foolz\SphinxQL\Drivers\Mysqli\Connection;


Answered By - rob006
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing