Home yii2 Debugging Tasks Yii2 Queue

Debugging Tasks Yii2 Queue

Author

Date

Category

Decided to send letters to use Yii2-Queue.

& lt;? php
Namespace App \ Models;
USE Yii \ Base \ BaseObject;
Use App \ Models \ NewSletter;
Use App \ Models \ Newsletterquene;
Class Newsletterjob Extends BaseObject IMPLEMENTS \ Yii \ Queue \ JobInterface
{
 Public $ newsletterid;
  Public Function Execute ($ Queue)
  {
    $ newsletter = newsletter :: find () - & gt; where (['id' = & gt; 8]) - & gt; one ();
    $ Mails = Newsletterquene :: Find () - & gt; where (['Status' = & gt; 1]) - & gt;
    Limit (\ Yii :: $ App- & gt; params ['newSletterCount']) - & gt; all ();
    $ changestatus = [];
    Foreach ($ Mails AS $ Mail) {
      \ Yii :: $ App- & gt; mailer- & gt; compose (
        'NewSletter',
        [
          'Content' = & gt; $ newsletter- & gt; message,
          'name' = & gt; $ Mail- & GT; Name
        ]
      )
        - & gt; setFrom (Yii :: $ App- & gt; params ['fromemail'])
        - & gt; setto ($ Mail- & gt; email)
        - & gt; SetSubject ($ newsletter- & gt; subject)
        - & gt; sen ();
      $ Mail- & gt; Status = 2;
      $ Mail- & gt; save ();
       $ changestatus [] = $ Mail- & gt; ID;
    }
    NewSletterquene :: Updateall (['Status' = & gt; 2], ['in', 'id', $ changstatus]);
  }
}

Here Job

Create a queue so

yii :: $ app- & gt; queue- & gt; push (new newsletterjob ([
      'newSletterid' = & gt; $ model- & gt; id
    ]));

Run in the console,
turn works out
No errors,
But nothing happens, no letters are sent, no status changes.
Question.
How to debug Joba
This is not the controller so that you can
$ this- & gt; stdout (VAR_DUMP (something);
Write.

output is not, and it is not clear, or if the error is that.
Queue is configured to work with DB
She works fine, see tasks,
I see that …


Answer 1, Authority 100%

php yii queue / run --verbose = 1-isolate = 0

verbose = 1 – for detailed output to the console

isolate = 0 – will work in one thread and it will be possible to work with xdebug (put the stop points)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions