Yii 1.1: PHPStorm & NetBeans autocomplete problem

15 followers

The problem: If you type Yii::app()->user<ctrl+space> code completion didn't work. This solve it.

PHPStorm 5

  1. /yii/framework/yii.php right click "Mark as Plain text"
  2. Create new php file in your project /protected directory named yii.php with this content:
<?php
 
class Yii extends YiiBase
{
    /**
     * Returns the application singleton or null if the singleton has not been created yet.
     * @return CWebApplication the application singleton, null if the singleton has not been created yet.
     */
    public static function app()
    {
        return self::app();
    }
}

That's all. Test it. Yii::app()->user->check<ctrl+space>

NetBeans

  1. Tools->Options->Miscellaneous->Files->Ignored Files Pattern
^(yiilite\.php|CVS|SCCS.....

Create new php file in your project /protected directory named yii.php with this content:

<?php
 
class Yii extends YiiBase
{
    /**
     * Returns the application singleton or null if the singleton has not been created yet.
     * @return CWebApplication the application singleton, null if the singleton has not been created yet.
     */
    public static function app()
    {
        return self::app();
    }
}

That's all. Test it. Yii::app()->user->check<ctrl+space>

Total 3 comments

#19393 report it
piotrch at 2015/06/16 03:48am
Thanks!

It's grate solution. Thanks for that!

#18641 report it
Almir at 2014/12/04 05:01pm
Extending CWebUser as WebUser

Hi guys,

I just created the Yii.php file as described in this page for code autocomplete fixing in NetBeans.

It worked good. The problem is Netbeans is identifying Yii::app()->user as CWebUser and not WebUser (where I put my extending methods).

How can I tell Netbeans the class of the user is WebUser?

Ps.: The methods are working, the problem is only with autocomplete.

Thanks! Almir

#13919 report it
zainiafzan at 2013/07/06 01:42am
Nice Tips.

Im using Yiinitializr.. So i put Yii.php in the root dir and it works.. thanks...

Leave a comment

Please to leave your comment.

Write new article