Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Create static helper classes
Create a class in a folder for example helper
set namespace app\helpers
your class will be available like this
app\helpers\ClassName::Method()
To connect functions and other stuff via BootstrapInterface
Create a class with yii\base\BootstrapInterface interface
namespace app\extensions\components;
use yii\base\Application;
use yii\base\BootstrapInterface;
class AppBootstrap implements BootstrapInterface
{
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap(Application $app)
{
// Подключаем файлик с функциями
}
}
'bootstrap' => [
'app\extensions\components\AppBootstrap',
],
I have a similar answer to Alexander N++ , but usually there is no need to include it as a class in the application.
My main helper class is located at app/components/Helper.php and has all the static functions I need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question