Skip to content

[Scheduler] Add example about how to pass arguments to a Symfony command #20278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2025
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
28 changes: 28 additions & 0 deletions scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,20 @@ The attribute takes more parameters to customize the trigger::
// defines the timezone to use
#[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')]

Arguments/options for Symfony commands are passed as plain string::

use Symfony\Component\Console\Command\Command;

#[AsCronTask('0 0 * * *', arguments: 'arg --my-option')]
class MyCommand extends Command
{
protected function configure(): void
{
$this->addArgument('my-arg');
$this->addOption('my-option');
}
}

.. versionadded:: 6.4

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

Arguments/options for Symfony commands are passed as plain string::

use Symfony\Component\Console\Command\Command;

#[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')]
class MyCommand extends Command
{
protected function configure(): void
{
$this->addArgument('my-arg');
$this->addOption('my-option');
}
}

.. versionadded:: 6.4

The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsPeriodicTask` attribute
Expand Down
Loading