areff
areff

Reputation: 145

How to include new php file/class in yii2?

i want to include pagination ajax class to yii2. how can i do that? when i use below code :

<?
	$url = Yii::app()->basePath.'/../vendor/phpunit/phpunit/src/Extensions/Pagination.php';
include $url;

?>

in controller and also below code:

require_once Yii::app()->basePath . '\..\vendor\phpunit\phpunit\src\Extensions\Pagination.php';

but both of them shows below error:

Call to undefined method Yii::app()

how can i fix it? is it true way to save pagination.php? please help me to include this file to my yii2 project..

thannks all :)

Upvotes: 0

Views: 908

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

You are using the wrong access to yii2 components

In yii2 you should use $app

Yii::$app->->basePath

and not Yii::app()

Upvotes: 1

Related Questions