I have a class called DataBaseHelper
which is defined in the file DataBaseHelper.php
:
<?php
namespace Company\Project\System\DataBaseHelper;
use Company\Project\System\RepoLink;
use mysqli;
use mysqli_result;
class DataBaseHelper
{
/* some cool stuff */
}
Inside of a file called helper.php
(with the namespace Company\Project\System;
) I use the following use Statement: use Company\Project\System\DataBaseHelper\DataBaseHelper;
:
<?php
namespace Company\Project\System;
use Company\Project\DataBaseHelper\DataBaseHelper\DataBaseHelper;
class CustomHelper
{
/* some cool stuff */
public function getDownloadCount(): string
{
try {
$query = "SELECT sum(count) c from downloads";
// The next line is line 258
$DBLink = new DataBaseHelper();
$result = $DBLink->getAssocResult($DBLink->executeQuery($query));
return $result["c"];
} catch (\Exception $e) {
// TODO: Errorhandling
return "ERROR";
}
}
}
Calling CustomHelper->getDownloadCount()
throws the following error:
> [15-Sep-2019 07:48:09 Europe/Berlin] PHP Fatal error: Uncaught Error: Class 'Company\Project\System\DataBaseHelper\DataBaseHelper'
> not found in
> /Applications/XAMPP/xamppfiles/htdocs/project/system/helper.php:258
> Stack trace:
> #0 /Applications/XAMPP/xamppfiles/htdocs/project/manage/index.php(49):
> Company\Project\System\RepoHelper->getDownloadCount()
> #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/project/system/helper.php on
> line 258
Is there anything missing with the namespaces? The use Statement inside helper.php
was automatically generated by my IDE (PHPStorm).
I do not use any frameworks.