I am using Slim 3 to build a rest API, and i have this structure
# models/user.php
<?php
class User {
public $id;
public $username;
public $password;
public $number;
public $avatar;
function __construct($id, $username, $password, $number, $avatar = null, $active = false) {
$this -> id = $id;
$this -> username = $username;
$this -> password = $password;
$this -> number = $number;
$this -> avatar = $avatar;
$this -> active = $active;
}
static function getByUsername($username) {
// i want to access the container right here
}
}
?>
i cant store the user model in the dependency container because, i can't have multiple constructors in PHP, and i can't access static methods from class instance? so how do i access the container from a service that can't be stored in the dependency container?