Fatal error: Class 'app\models\Auction' not found
Hello! i use Yii2, install your extestion via composer and in root directory create file: `<?php namespace app;
require_once './vendor/workerman/workerman/Autoloader.php'; use Workerman\Worker; use Workerman\Lib\Timer; use app\models\Auction;
$task = new Worker();
$task->onWorkerStart = function($task){
$time_interval = 5;
$timer_id = Timer::add($time_interval,
function(){
$endedAuctionExist = Auction::find()->where(['ended_at'=>2])->exists();
if($endedAuctionExist){
$auctions = Auction::find()->where(['ended_at'=>2])->all();
foreach($auctions as $auction){
/* @var $auction Auction */
$auction->winner_id = 10;
$auction->save();
}
}
}
);
};
Worker::runAll();And i get this on start:Workerman[auction.php] start in DEBUG mode
----------------------- WORKERMAN -----------------------------
Workerman version:3.3.4 PHP version:5.4.16
------------------------ WORKERS -------------------------------
user worker listen processes status
root none none 1 [OK]
Press Ctrl-C to quit. Start success. PHP Fatal error: Class 'app\models\Auction' not found in auction.php on line 14 Fatal error: Class 'app\models\Auction' not found in auction.php on line 14 WORKER EXIT UNEXPECTED E_ERROR Class 'app\models\Auction' not found in auction.php on line 14 worker[none:16741] exit with status 65280`
You can try to use autoload.php of composer.
Can you explain in more detail, thx.
See http://php.net/manual/en/function.spl-autoload-register.php .