I would create two main classes in PHP5: 1- Database 2- Session These two classes will be used in a page "index.php" (and many others) in order to provide connection to the database and the use of session in future queries. I could simply make two objects and use them as in the following example:
require('Session.php');
require('Database.php');
$session = new Session();
$session->startSession();
$database = new Database();
$database->query();
But I don't like very much this solution. I would recall in my "index.php" just one class called Processor.php and recall both Session and Database classes too.
I would see this:
require('Processor.php');
$session = ...? call all methods of session
$session->
$database = ..? call all methods of database
$database->
How can I implement this idea? I would make that with Singleton pattern. Who can help me?