Skip to content
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

[5.3] Option to schedule tasks using the command class instead of it's signature #15591

Merged
merged 3 commits into from
Sep 26, 2016
Merged

[5.3] Option to schedule tasks using the command class instead of it's signature #15591

merged 3 commits into from
Sep 26, 2016

Conversation

KennedyTedesco
Copy link
Contributor

To schedule a task:

Kernel.php

<?php

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        PayablesCommand::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('payables:update')->dailyAt('23:55');
    }
}

This PR adds the ability to do this:

<?php

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        PayablesCommand::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command(PayablesCommand::class)->dailyAt('23:55');
    }
}

@taylorotwell
Copy link
Member

What if the command has dependencies?

@KennedyTedesco
Copy link
Contributor Author

Good catch. I have updated the approach of the instantiation.

@taylorotwell taylorotwell merged commit 6219249 into laravel:5.3 Sep 26, 2016
@KennedyTedesco KennedyTedesco deleted the command-5.3 branch September 26, 2016 14:28
@KennedyTedesco
Copy link
Contributor Author

Can someone update the docs? Would be much appreciated.

https://github.com/laravel/docs/blob/5.3/scheduling.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants