I'm doing a simple system using php with mvc structure and I want to use the namespace, however, of the error stating that it does not find the Data class.
Error: Fatal error: Class 'Config \ Database \ Data' not found in /home/andre/www/mvc-mercado/controller/index.controller.php on line 8
View file:
<?php
include 'controller/index.controller.php';
?>
<!DOCTYPE html>
<html> ....
File index.controller.php that gives the error in new DB ():
<?php
use Config\Database\Data as DB;
class IndexController {
public function __construct() {
// instancia base de dados
$database = new DB();
}
}
new IndexController();
Data.config.php file
<?php
namespace Config\Database;
class Data {
public $dbcon;
public function __construct() {
// abre conexão com o banco
$this->dbcon = pg_connect("host=localhost port=5432 dbname=mercado user=silva password=12345");
}
public function __destruct() {
// fecha conexão com o banco
pg_close($this->dbcon);
}
}