Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,34 @@ Scheduling Recurring Messages
A ``RecurringMessage`` is a message associated with a trigger, which configures
the frequency of the message. Symfony provides different types of triggers:

:class:`Symfony\\Component\\Scheduler\\Trigger\\CronExpressionTrigger`
A trigger that uses the same syntax as the `cron command-line utility`_.

:class:`Symfony\\Component\\Scheduler\\Trigger\\CallbackTrigger`
A trigger that uses a callback to determine the next run date.

:class:`Symfony\\Component\\Scheduler\\Trigger\\ExcludeTimeTrigger`
A trigger that excludes certain times from a given trigger.

:class:`Symfony\\Component\\Scheduler\\Trigger\\JitterTrigger`
A trigger that adds a random jitter to a given trigger. This allows to
distribute the load of the scheduled tasks instead of running them all
at the same time.

:class:`Symfony\\Component\\Scheduler\\Trigger\\PeriodicalTrigger`
A trigger that uses a ``DateInterval`` to determine the next run date.

Most of them can be created via the :class:`Symfony\\Component\\Scheduler\\RecurringMessage`
class, as we'll see in the following examples.

Cron Expression Triggers
~~~~~~~~~~~~~~~~~~~~~~~~

It uses the same syntax as the `cron command-line utility`_::

RecurringMessage::cron('* * * * *', new Message());

Before using it, you must install the following dependency:
Before using it, you have to install the following dependency:

.. code-block:: terminal
Expand Down Expand Up @@ -224,7 +244,7 @@ Then, define your recurring message::
new SendDailySalesReports('...'),
);

Finally, the recurring messages must be attached to a schedule::
Finally, the recurring messages has to be attached to a schedule::

// src/Scheduler/MyScheduleProvider.php
namespace App\Scheduler;
Expand Down