workerman icon indicating copy to clipboard operation
workerman copied to clipboard

Fatal error: Class 'app\models\Auction' not found

Open impuulse opened this issue 10 years ago • 3 comments

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`

impuulse avatar Oct 03 '16 07:10 impuulse

You can try to use autoload.php of composer.

walkor avatar Oct 03 '16 07:10 walkor

Can you explain in more detail, thx.

impuulse avatar Oct 03 '16 08:10 impuulse

See http://php.net/manual/en/function.spl-autoload-register.php .

walkor avatar Oct 17 '16 12:10 walkor