Here are two way to initialize class variables.
class Test {
private $var1;
private $var2;
public function Test($var1,$var1) {
My mind is that you should combine both methods.
Properties that are unavoidable must be present in a construct method.
For properties that are optional, you should define default value in the construct then create getter/setter.
And you can create multiple construct methods like for database, in generally, you have:
myConstructor($dsn)
myConstructor($dsn, $username, $password)
myConstructor($dsn, $username, $password, $port)
myConstructor($dsn, $username, $password, $port, $options)
Then in the "bottom" construct you will set $options
then call the "upper" construct that will set the $port
and will call "upper" construct... etc...