0
I’m making 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 archive:
<?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();
File data.config.php
<?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);
}
}
My comment is unrelated to the error of the question... In MVC is not the
view
who carries the controller.– Papa Charlie