Your problem has little to do with M.V.C., and more related to use global variables or global values.
Many of this classes, usually require one instance per class ("singletons"), and, in some circumstances, singletons cannot be avoided, and in your case, are OK to have them.
What many books, tutorials, doesn't teach, its how when or where should singletons be initialized. Its changes from programming language to programming language.
And, in the case of web sites, where variables loose their values when changing to another page, that becomes complicated.
There is this concept called "session variables", that work togheter with singletons, that allow to keep values when chaning from one page to another:
http://php.net/manual/en/session.examples.basic.php
Let's suppouse you have a website. It has several files, and several pages. Some of those php files are called directly and considered "web pages", example "index.php" .
Other php files, are library files, and are "required" or "included" by other files, and are not considered "web pages" by themselves.
When a user click a link in a wbe page, and the browser calls another web page, al lthose values may get lost. Its not like opening another form in a desktop application.
Think, when an user enters a website for the first time (example: "index.php"): the main file "includes" or "requires" other files, and initializes global variables or singletons:
<?php
// filename: "config.php"
// another includes or requires here
class Config
{
// begin data section
public static $UserName;
public static $UserPassword;
// end data section
// begin singleton section
private static $_instance;
public static function getInstance()
{
if (!self::$_instance instanceof self)
{
self::$_instance = new self;
}
return self::$_instance;
}
// end singleton section
// start session section
public static function SaveSession()
{
$_SESSION['config_username'] = Config::$UserName;
$_SESSION['config_password'] = Config::$UserPassword;
}
public static function RestoreSession()
{
Config::$UserName = $_SESSION['config_username'];
Config::$UserPassword = $_SESSION['config_password'];
}
// end session section
} // class Config
?>
<?php
// filename: "index.php"
include ("config.php");
// another includes or requires here
class Application
{
public static function main()
{
// prepare session variables
session_start();
// prepare singletons here
$instance = Config::getInstance();
// this code its an example
$instance->UserName = "johndoe";
$instance->UserPassword = "123";
$instance->SaveSession();
// all the page construction goes here
// ...
}
} //
// program starts here:
Application::main();
?>
When the user, changes to another page, the application, must reload the session data into the singletons.
<?php
// filename: "customers.php"
include ("config.php");
// another includes or requires here
class Application
{
public static function main()
{
// copy data from session to singletons
$instance->RestoreSession();
// all the page construction goes here
// ...
}
} //
// program starts here:
Application::main();
?>
There is not relation among the singletons, usually they are independent values.
Cheers.