1
I’m trying to understand the MVC pattern but there are so many videos differently on the web that mess the understanding.
I, in turn, am using a pattern of my own. But I would like to know if it is correct, otherwise, what would be the proper form.
I’m using in 2 layers of classes and one in a separate file.
Example:
Table: Customers
MVC/Model/Clients.php
class Clientes {
$id;
$nome;
$idade;
public function __construct() {}
/**
Getteres e Setteres
**/
}
MVC/View/Clients.php
class Clientes {
public function __construct() {}
/**
métodos de gravação,alteração e leitura no banco
**/
}
MVC/Controller/Clients.php
require_once '../Controller/Clientes';
require_once '../Model/Clientes';
$clientes = new Clientes();
$clientesLista = $clientes->listaClientes();
index php.
require_once "MVC/Controller/Clientes.php";
Is that the idea? Or am I totally on the outside?
If this is not the case, please post a very simple example like the one I posted. Preferably using terms known as class Clientes
and please avoid examples like Class foo
, foo->bar
.
In his View you are putting methods to "recording", and that is not the purpose of View, it must be "what the user sees" in a simple way, i.e., it must receive the Model and generate the
html
for the user. The methods to save/read data must be in the Controller– Ricardo Pontual
See https://answall.com/questions/114824/como-e-para-que-usar-mvc-no-php/116392#116392
– BrunoRB