Answer the question
In order to leave comments, you need to log in
How to add comments for locator service in Yii 2?
I use phpstorm, I love it when all variables are prompted and highlighted.
Where can I specify that Yii::$app->cart is an instance of /some/namespace/Cart ?
Answer the question
In order to leave comments, you need to log in
There is a solution from Alexander Makarov : https://github.com/samdark/yii2-cookbook/blob/mast...
I also got a little tired that the autocomplete for my components does not work. What you have to do all the time:
/** @var LanguageManager $languageManager */
$languageManager = Yii::$app->languageManager;
class Yii extends \yii\BaseYii
{
/**
* @var BaseApplication|WebApplication|ConsoleApplication
*/
public static $app;
}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
abstract class BaseApplication extends \yii\base\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class WebApplication extends \yii\web\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class ConsoleApplication extends \yii\console\Application {}
I created a file with shortcuts, and wrote something like this:
// EDIT
I thought it was Yii first version. But you can do the same with the second one.
/** @return CWebApplication|CConsoleApplication */
function app()
{
return Yii::$app;
}
/** @return CHttpRequest */
function req()
{
return Yii::$app->getComponent('request');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question