Build worker queue with codeigniter

Viewed 769

I'm, trying to make a worker using this repo and redis

https://github.com/yidas/codeigniter-queue-worker

but i don't find any complete tutorial how to use it. I've tried to use it manual but no luck and keep throwing error, i don't know how to completely build the worker.

if there's any of you have tried or using it, please help to build worker with this lib.

I need to grab around 1 million or more data and build a new database from that data, and i think can't be done by just using 1 single call query, that's why i'm trying to grab all data by using worker so those data can be grabbed consistently without any error.

TRY CASE I'm trying to load the lib with "use"

<?php if(!defined('BASEPATH')) exit ('No direct script access allowed!');

use vendor\yidas\queue\sec\Controller' as WorkerController;

class User_register_unverified extends WorkerController{

    function __construct(){
        parent::__construct();
    }

    function index(){
        echo 'Test';
    }

}

I Got this Error

An uncaught Exception was encountered
Type: ParseError

Message: syntax error, unexpected '' as WorkerController;' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'

Filename: /var/www/html/lists/services/application/controllers/User_register_unverified.php

Line Number: 9

Backtrace:

File: /var/www/html/lists/services/index.php
Line: 320
Function: require_once

I Try to move the lib to "libraries" codeigniter directory and use require_once and i change the class name to "Worker"

<?php if(!defined('BASEPATH')) exit ('No direct script access allowed!');

// use vendor\yidas\queue\sec\Controller' as WorkerController;
require_once APPATH.'libraries/Worker' as WorkerController;

class User_register_unverified extends WorkerController{

    function __construct(){
        parent::__construct();
    }

    function index(){
        echo 'Test';
    }

}

Also get same error

An uncaught Exception was encountered
Type: ParseError

Message: syntax error, unexpected 'as' (T_AS)

Filename: /var/www/html/lists/services/application/controllers/User_register_unverified.php

Line Number: 4

Backtrace:

File: /var/www/html/lists/services/index.php
Line: 320
Function: require_once

Then i tried to use as lib

<?php if(!defined('BASEPATH')) exit ('No direct script access allowed!');

// use vendor\yidas\queue\sec\Controller' as WorkerController;
// require_once APPATH.'libraries/Worker' as WorkerController;

class User_register_unverified extends CI_Controller{

    function __construct(){
        parent::__construct();
        $this->worker  = $this->load->library('worker');
    }

    function index(){
        echo 'Test';
    }

}

and i got this notif

An Error Was Encountered
Non-existent class: Worker

I noticed that i did wrong type directory in "use" way and repaired it

<?php if(!defined('BASEPATH')) exit ('No direct script access allowed!');

use vendor\yidas\queue\src\Controller as WorkerController;

class User_register_unverified extends WorkerController{

    function __construct(){
        parent::__construct();
        // $this->worker  = $this->load->library('worker');
    }

    function index(){
        echo 'Test';
    }

}

Yet, still get the same error

Fatal error: Class 'vendor\yidas\queue\src\Controller' not found in /var/www/html/lists/services/application/controllers/User_register_unverified.php on line 6
A PHP Error was encountered
Severity: Error

Message: Class 'vendor\yidas\queue\src\Controller' not found

Filename: controllers/User_register_unverified.php

Line Number: 6

Backtrace:
1 Answers

You can use like this

    <?php
use yidas\queue\worker\Controller as WorkerController;

class Job extends WorkerController {
Related