Hello friends.
I create a helper and I put in folder "Helpers", I set the path in web/index.php:
<?php
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../helpers/Utils.php'); // my helper
$config = require(__DIR__ . '/../config/web.php');
(new yii\web\Application($config))->run();
So to use in a view this is the way:
<?= yii\helpers\Utils::doSomeThing("test") ?>
Worked well, but why I need put "yii\helpers\"? I think i can use:
<?= Utils::doSomeThing("test") ?>
Is it possible?