I'm in the middle of trying to move components of my website into classes. This snippet below for example needs to be used in multiple files, but I don't want to copy and paste the code around.
<?php
...
require "ActionManager.php";
require "Action.php";
require "includes/pdo.php";
$actionMan = new ActionManager();
$actionMan->setPDO($pdo);
$actionMan->setUserData($data);
echo $actionMan->getActions(3);
?>
Okay I know I could use spl_autoload_register() to get rid of the first two requires, but I think what I'm looking for is some kind of dependency container, so that I don't end up repeating this code, and screwing myself over when it changes.
Also I find myself repeating the setPDO() and setUserData() methods in a LOT of classess.
Could someone kindly point me in the right direction?