How to call controller from Task and act as am call normal route

Why just not create service which be used in controller and task ?

How can i do that?

Am already have websrevice and have route to call specific action from controller but i don't want to call it and i need to make cron job using Task which call the action from controller



67.7k
edited Nov '15

Controller.php


class Controller extends Controller {

    public function customAction(){
        $data = [
            'id' => 15000,
            'type' => 'new_employee'
            'whatever' => 'whatever'
        ];
        new \MyApp\Module\Lib\Transfers($data);
    }
}

then your cron / queue can be calling /var/www/myapp/modules/mymodule/lib/Transfers.php

?

Now i have controller which contains function send en email and use view and i need to call this function from task to send the email



67.7k

i use php-resque to send emails ( https://github.com/chrisboulton/php-resque)

i think it is in top 3 solutions out there. Also when you create workers, you dont have to mix the logick with phalcon itself.

I have my workers expecting, email template path, variables for the template, and email/emails. After that the queue jobs takes care of the reset.

I dont see a reason why you have to mix workers with phalcon ?

Finally i did it, As i need to use MVC model I can use everything in cli.php as in index.php then i can call any function anywhere