get count in relation table in yii2 Activerecord

I have two table for post and user. I want to show post count of user in users list gridview. In yii 1 I use this in model to define a relation for this purpose:

‘postCount’ => array(self::STAT, ‘Post’, ‘author’,

        'condition' => 'status = ' . Post::ACTIVE),


But i don’t know how to implement this in Yii2 to get count of post in User:find():with(’…’) to show in gridview.

Anyone try this in yii2?