I make a custom component(getter).
My custon component works well, because I test from a controler:
namespace app\controllers;
use Yii;
(...)
class SiteController extends Controller
{
(...)
public function actionTest()
{
//OK, print numItems
echo '<br>-Items: '.Yii::$app->getter->numItems;
}
}
Now I want to use my component from standard php file. This php file is inside the Yii project structure in cmd dir.
namespace app\cmd;
use Yii;
echo "Import ok<br>";
echo '<br>-Items: '.Yii::$app->getter->numItems;
echo "Script end";
The result of run script is "Import ok" and Fatal error: Class 'Yii' not found
.
Why do I get a 'Class not found' error?