Updated
I have a memory overflow problem in a layered architecture, the development has been going on for several years and they have tried to optimize some parts but the main problem lies in the Instances of the classes in the sub-layers
I list it in the following way so that we have a general idea of how the structure is:
Layer1
File Index.php
require_once "control/class.Main.php"; #hacemos el require once a la libreria Main de nuestra APP
$WebAPP = new Class_MAIN();
$WebAPP->Main(); #llamamos a la Funcion Main
Capa2
Main.php File
class Class_MAIN {
public function __construct() {
require_once 'control/config/config.externas.php'; #este archivo realiza un include de las librerias externas
require_once 'control/config/config.genericas.php'; #este archivo realiza un include de las librerias genericas
require_once 'control/config/config.modulos.php'; #este archivo realiza un include de las modulares
//el archivo config.modulos.php se encarga de hacer include de otros archivo
//en este caso class.content.php y class.menu.php
#Instanciamos las clases necesarias
$this->CONTENTMANAGER = new Class_ContentManager(); #el contenido a Mostrar por pantalla.
}
#llamada a la clase que genera el Display
public function Main() {
$this->CONTENTMANAGER->Gen_Display(); # Genera el Codigo html de la pagina.
}
}
Capa3
class.content.php file in layer 3 we can locate the CONTENTMANAGER class mentioned in layer 2, this initializes classes that were included (require_once) in layer 2. the GetMenuSide function raises some files by require_once that are actually html. as we see in the constructor for the first time we see Class Class_BDManager that is intact
class Class_ContentManager{
public function __construct() {
#Llamamos a los archivos que se requieren para el funcionamiento de la pagina
$this->MENUMANAGER = new Class_MenuManager();
$this->FORMMANAGER = new Class_FormManager();
$this->PROCESSMANAGER = new Class_ProcessManager();
$this->MODALSMANAGER = new Class_ModalManager();
$this->DBMANAGER = new Class_BDManager();
}
function GetMenuSide() {
require_once "sources/tpl/navside/start.side.php";
$this->MENUMANAGER->MenuSideManager();
require_once "sources/tpl/navside/end.side.php";
}
}
Capa4
class.menu.php file we can say that in this layer is the MenuSideManager class mentioned in layer 3 and that in turn initializes classes again $ this- > DBMANAGER = new Class_BDManager (); that were included in layer 2
class Class_MenuManager{
public function __construct() {
$this->DBMANAGER = new Class_BDManager();
}
function MenuSideManager(){
#Consulta permisos del menu
}
}
if we see $ this-> DBMANAGER = new Class_BDManager (); is Installed for some reason in 2 layers 3 and 4, and as far as I understand the system does the same in layer 5, 6, 7, 8; I also observe that not only is it a class, let's say that this happens with classes by blocks:
External Classes
Generic classes
Classes to generate Views (Lists Etc)
only Generic classes perform these call intancias, for each class file in the module section that would be layer 6:
$this->COOKIESMANAGER = new Class_CookiesManager();
$this->CRIPMANAGER = new Class_CripManager();
$this->DATEMANAGER = new Class_DateManager();
$this->DBMANAGER = new Class_BDManager();
$this->ERRORMANAGER = new Class_ErrorManager();
$this->FILEMANAGER = new Class_FileManager();
$this->HTTPDATAMANAGER = new Class_HTTPDataManager();
$this->LOGSMANAGER = new Class_LogsManager();
$this->MEMORYMANAGER = new Class_MemoryManager();
$this->URLMANAGER = new Class_UrlManager();
$this->USERMANAGER = new Class_UserManager();
$this->CRUDMANAGER = new Class_CrudManager();# permisos
$this->SESSIONMANAGER = new Class_SessionManager();
$this->EMAILMANAGER = new Class_EmailManager();
$this->ORDERMANAGER = new Class_OrderManager();
$this->VARMANAGER = new Class_VarManager();
$this->FTPMANAGER = new Class_FtpManager();
the part of the require_once is done dynamically with the following script:
<?php
class Class_MAIN{
protected $ObjClass;
protected $ObjNameclass;
public function __construct() {
require_once 'const/Constant.php';
require_once 'class/ClassManager.php';
$this->AUTOLOAD = new ClassManager();
$this->ObjClass = [];
$this->ObjClass = $this->AUTOLOAD->LoadClass($this->ObjClass);
foreach ($this->ObjClass as $key => $Class) {
require_once $Class;
}
#aqui se instanciaran solo las clases necesarias
}
public function Main() {
#aqui iran las funciones necesarias
}
}
?>
The main idea or objective is:
inherit in some way the instantiation of the classes through a public object that can be accessed from any of the sub-layers and make direct use of the functions that are in the generic classes, an example of a query based on serious data something like this:
#$this->ObjNameclass['DBManager'] puede ser la propiedad declara o objeto eredado
$this->$this->ObjNameclass['DBManager']->BDQuery(datos);
I know that they will tell me how best to use a framework but that would indicate that I must complete a development that has been going on for 6 years, and also many files to edit for each layer, I would look for ways to edit these files as little as possible. I'm looking for a solution based on this same architecture.
I will be doing other updates with more details implementing the responses of the partners.