PHP Slim 3 Framework - Use MonoLog in Custom Class - Using $this when not in object context
问题 Im am working from the Slim 3 skeleton and trying to use the MonoLog in a custom class I have created which is called Utilities. Utilities.php - which is required from index.php <?php class Utilities { protected $logger; function __construct($c) { $this->logger = $logger; } static function checkPerms() { $this->logger->info("checkPerms() permissions of user id valid."); return true; } } Dependencies.php - I added the following: $container['utilities'] = function ($c) { return new Utilities($c