Reputation: 373
I'm trying to use this library: https://github.com/duzun/hQuery.php
My project is ordonated like this:
BetCompare
Application
Teams
file_using_the_library.php
hQueryLib
hquery.php
So here is how I'm using it in my php file:
namespace BetCompare\Application\Teams;
use BetCompare\Application\Teams\hQueryLib\hquery;
hQuery::$cache_path = "/path/to/cache";
This returns an error Class not found
. I've tried this after a few researches on the matter:
namespace BetCompare\Application\Teams;
use BetCompare\Application\Teams\hQueryLib\hquery;
include_once 'hQueryLib/hquery.php';
hQuery::$cache_path = "/path/to/cache";
Then the error is the following: Cannot declare class hQuery_Context, because the name is already in use
. I don't understand, the second error makes it look like the use
was enough and loaded the class. But I can't use it... What am I doing wrong?
I've also tried only using include_once
but it doesn't work.
Upvotes: 1
Views: 901
Reputation:
Either like this (with namespace duzun\hQuery
):
<?php
namespace BetCompare\Application\Teams;
use duzun\hQuery;
include_once 'hQueryLib/hquery.php';
hQuery::$cache_path = "/path/to/cache";
or like this, without the namespace:
<?php
namespace BetCompare\Application\Teams;
include_once 'hQueryLib/hquery.php';
\hQuery::$cache_path = "/path/to/cache";
Your code can not work, because if you write
use BetCompare\Application\Teams\hQueryLib\hQuery;
you are practically assuming, that the hQuery
class has the namespace definition
namespace BetCompare\Application\Teams\hQueryLib;
which it does not have (beeing a third-party class).
The part with the duzun\hQuery
is defined in the last lines of the hQuery.php
file and described in the docus.
Upvotes: 4