The class candidateService declared namespace app\services; I import it in another class use app\services\candidateService as candidateService; , but PHP does not see it:
Fatal error: Class 'app \ models \ candidateService' not found in Z: \ home \ test.ru \ www \ index.php on line 8
What could be the problem?
index.php
use app\services\candidateService as candidateService; $candidateService = new candidateService(); $candidate = $candidateService->getCandidate(1); print_r($candidate); candidateService.php
namespace app\services; use app\managers\dbManager as Database; class candidateService { private $Surname, $Name, $Patronymic, $Mail, $LastContact, $Status, $Vacancies, $Database = null; public function __construct() { $this->Database = new Database(); } public function getCandidate($id) { return $this->Database->Query("SELECT * FROM `candidates` WHERE `id`='$id';"); } }
use app\services\candidateServiceenough touse app\services\candidateServiceif you don’t want to use an alias for this class. Secondly, how do you include the class itself? - YuS