Skip to content

Allow passing environment variables to scheduled tasks#13

Closed
jradtilbrook wants to merge 1 commit intoilluminate:masterfrom
jradtilbrook:schedule-env
Closed

Allow passing environment variables to scheduled tasks#13
jradtilbrook wants to merge 1 commit intoilluminate:masterfrom
jradtilbrook:schedule-env

Conversation

@jradtilbrook
Copy link
Contributor

@jradtilbrook jradtilbrook commented Nov 25, 2025

With this change, it allows us to pass environment variables to scheduled tasks similar to the Process facade.

Useful for commands or any other schedule tasks that need to override the environment variable for some uses but not all.

Example routes/console.php:

<?php

// process podcasts in default english
Schedule::command('app:process-podcasts')->everyHour();
// process podcasts in french
Schedule::command('app:process-podcasts')->env(['LANG' => 'fr'])->everyHour();

// prior:
Schedule::exec('LANG=fr php artisan app:process-podcasts')->everyHour();

This is only applicable to ::exec() and ::command() tasks that use the Symfony process package. ::job() and ::call() do not use it. As such, the method is overridden to throw an exception similar to runInBackground()

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.

1 participant