1
1
Scheduler
2
2
=========
3
3
4
- .. versionadded :: 6.3
5
-
6
- The Scheduler component was introduced in Symfony 6.3
7
-
8
4
The scheduler component manages task scheduling within your PHP application, like
9
5
running a task each night at 3 AM, every two weeks except for holidays or any
10
6
other custom schedule you might need.
@@ -140,6 +136,9 @@ It uses the same syntax as the `cron command-line utility`_::
140
136
141
137
RecurringMessage::cron('* * * * *', new Message());
142
138
139
+ // optionally you can define the timezone used by the cron expression
140
+ RecurringMessage::cron('* * * * *', new Message(), new \DateTimeZone('Africa/Malabo'));
141
+
143
142
Before using it, you must install the following dependency:
144
143
145
144
.. code-block :: terminal
@@ -151,10 +150,6 @@ Before using it, you must install the following dependency:
151
150
Check out the `crontab.guru website `_ if you need help to construct/understand
152
151
cron expressions.
153
152
154
- .. versionadded :: 6.4
155
-
156
- Since version 6.4, it is now possible to add and define a timezone as a 3rd argument
157
-
158
153
Periodical Triggers
159
154
~~~~~~~~~~~~~~~~~~~
160
155
@@ -263,9 +258,9 @@ the Messenger component:
263
258
.. image :: /_images/components/scheduler/generate_consume.png
264
259
:alt: Symfony Scheduler - generate and consume
265
260
266
- .. versionadded :: 6.4
261
+ .. tip ::
267
262
268
- Since version 6.4, you can define your messages via a ``callback `` via the
263
+ You can also define your messages via a ``callback `` using the
269
264
:class: `Symfony\\ Component\\ Scheduler\\ Trigger\\ CallbackMessageProvider `.
270
265
271
266
Debugging the Schedule
@@ -291,11 +286,11 @@ recurring messages. You can narrow down the list to a specific schedule:
291
286
15 4 */3 * * App\Messenger\Foo(0:17..) Mon, 18 Dec 2023 ...
292
287
-------------------- -------------------------- ---------------------
293
288
294
- .. versionadded :: 6.4
289
+ # you can also specify a date to use for the next run date:
290
+ $ php bin/console --date=2025-10-18
295
291
296
- Since version 6.4, you can even specify a date to determine the next run date
297
- using the ``--date `` option. Additionally, you have the option to display
298
- terminated recurring messages using the ``--all `` option.
292
+ # use the --all option to also display the terminated recurring messages
293
+ $ php bin/console --all
299
294
300
295
Efficient management with Symfony Scheduler
301
296
-------------------------------------------
0 commit comments