I have class with my logic.
class BlogApp
class BlogApp
{
public static $app;
public function __construct()
{
self::$app = Registry::instance();
$this->getParams();
}
class Registry
class Registry
{
use TSingletone;
protected static $properties = [];
public function setProperty($name, $value)
{
self::$properties[$name] = $value;
}
public function getProperty($name)
{
if (isset(self::$properties[$name])) {
return self::$properties[$name];
}
return null;
}
public function getProperties()
{
return self::$properties;
}
I want to use my class BlogApp { } anywhere in the controllers to store properties. For example
BlogApp::$app->setProperty('img_width', 1280);
$wmax = BlogApp::$app->getProperty('img_width');
and my public/index.php
new \App\BlogApp();
but I have exception
Call to a member function getProperty() on null
if I use this one
$d = new BlogApp();
$d::$app->getProperty('img_width');
No problem. But I want
$wmax = BlogApp::$app->getProperty('img_width');
where is my mistake ?