In Yii2, you can use the count() and groupBy() methods in the query builder to count and group the results of a query, respectively.
In Yii2, you can use the following code to get the root directory: