Answer the question
In order to leave comments, you need to log in
How to install third party extension for Yii2?
Hello! I want to install wiki.workerman.net/Workerman_documentation#Installation
I add it
to composer, I create a file at the root with the following content:
namespace app;
use Workerman\Worker;
use Workerman\Lib\Timer;
use app\models\Auction;
require_once './vendor/workerman/workerman/Autoloader.php';
$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();
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 15
Answer the question
In order to leave comments, you need to log in
php already told you:
PHP Fatal error: Class 'app\models\Auction' not found in auction.php on
line
15 app\models\auction.php ? does it really have namespace app\models ? And wasn't the path to app (application directory) overridden? Nothing else should fail.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question