dimanche 10 juillet 2022

php use classes in specific environment [duplicate]

I would like to write a website who shows server specific parameters like: temperature, processoruse, ...

This code is different on windows and linux. (I use windows for development and linux for production).

Is tere a design pattern who automaticaly knows which class to use?

I imagined something like this:

class Controller{
    public Main $main = new Main();
    public $temperature = $main->getTemertature;
}

class Main{
    public int getTemperature(){
        //get temperature of current environment
    }
}

class MainProduction{
    public int getTemperature(){
        //linux code
    }
}

class MainDevellopment{
    public int getTemperature(){
        //windows code
    }
}

Aucun commentaire:

Enregistrer un commentaire