title: Yii2 - How to get the current username or name from Yii::$app->user?
body: <p>How do you add, or get, variables using <code>Yii::$app-&gt;user-&gt;something</code>?</p>
  
  <p>I don't want to get them through <code>identity</code>. I want to make specific ones accessible through <code>user</code>.</p>
  
  <p>For example, I want to get the current logged in user's username and name:</p>
  
  <pre><code>\Yii::$app-&gt;user-&gt;username
  </code></pre>
  
  <p>or</p>
  
  <pre><code>\Yii::$app-&gt;user-&gt;name
  </code></pre>