Answer the question
In order to leave comments, you need to log in
Connecting PHP file in controller?
Good afternoon!
It is necessary to include a php file of a third-party library.
Located at the root of the folder.
Everything is fine in the view, but how to connect it in the controller?
public function actionGoogle() {
require_once Yii::$app->basePath.'\google\GoogleAuthenticator.php';
$ga = new GoogleAuthenticator;
return $this->render('google', [
'ga' => $ga
]);
Answer the question
In order to leave comments, you need to log in
Good evening.
Check out the namespace .
Example.
The file is located in the components directory
In the required file, specify the location where the required file is located
//указываете пространство имён
use components\GoogleAuthenticator;
//используете
$ga = new GoogleAuthenticator;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question