1) You can use yii global app params
Yii::$app->params['foo'] = 'bar'; // controller
and
echo Yii::$app->params['foo']; // in view/layout/controllers/elsewhere
2) You can use session. Create a controller, that will be extended by others, with these 3 functions:
<?php
namespace common\components;
use Yii;
use yii\web\Controller;
class BaseController extends Controller
{
    /**
     * Set user flash notice
     * @param $message
     * @return mixed
     */
    public function setFlash($key, $message){
        return Yii::$app->session->setFlash($key, $message);
    }
    /**
     * Has user flash notice
     * @param $message
     * @return mixed
     */
    public function hasFlash($key){
        if(Yii::$app->session->hasFlash($key)) return True;
        else return false;
    }
    /**
     * Get user flash notice
     * @param $message
     * @return mixed
     */
    public function getFlash($key){
        return Yii::$app->session->getFlash($key);
    }
}
now in your controllers
use common\components\BaseController;
...
class MyController extends BaseController
...
$this->setFlash('foo','bar'); // setting flash var
and in your views
echo $this->context->getFlash('foo'); // getting flash var
or
echo Yii::$app->controller->getFlash('foo'); // getting flash var