Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc90d83

Browse filesBrowse files
committed
[Scheduler] Add example about how to pass arguments to a Symfony command
1 parent 7b081aa commit fc90d83
Copy full SHA for fc90d83

File tree

Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed

‎scheduler.rst

Copy file name to clipboardExpand all lines: scheduler.rst
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,20 @@ The attribute takes more parameters to customize the trigger::
473473
// defines the timezone to use
474474
#[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')]
475475

476+
Arguments/options for Symfony commands are passed as plain string::
477+
478+
use Symfony\Component\Console\Command\Command;
479+
480+
#[AsCronTask('0 0 * * *', arguments: 'arg --my-option')]
481+
class MyCommand extends Command
482+
{
483+
protected function configure(): void
484+
{
485+
$this->addArgument('my-arg');
486+
$this->addOption('my-option');
487+
}
488+
}
489+
476490
.. versionadded:: 6.4
477491

478492
The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsCronTask` attribute
@@ -522,6 +536,20 @@ The ``#[AsPeriodicTask]`` attribute takes many parameters to customize the trigg
522536
}
523537
}
524538

539+
Arguments/options for Symfony commands are passed as plain string::
540+
541+
use Symfony\Component\Console\Command\Command;
542+
543+
#[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')]
544+
class MyCommand extends Command
545+
{
546+
protected function configure(): void
547+
{
548+
$this->addArgument('my-arg');
549+
$this->addOption('my-option');
550+
}
551+
}
552+
525553
.. versionadded:: 6.4
526554

527555
The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsPeriodicTask` attribute

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.