O
O
Oleg2019-11-06 16:06:54
PHP
Oleg, 2019-11-06 16:06:54

How to create a similar structure Class1::$app->class2->method()?

In Yii, you can call other classes and their methods through the main class. For example, Yii::$app->security->getRandomString(). And how is it possible to create such a structure? Or is there a common name for something like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2019-11-06
@miraage

Yii::$app is a static class property. In fact, something like a singleton. Total - anti-pattern.
https://github.com/yiisoft/yii2/blob/2.0.29/framew...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question