Undefined constant 'STDIN'
/tmp/vendor/symfony/console/Helper/QuestionHelper.php:110
You will see this error if you try to run some artisan commands programmatically from within an HTTP request:
Route::get('/queue-clear', function () {
Artisan::call('queue:clear');
});
This is because Laravel will try to prompt for confirmation if the application is running in the production environment. While doing so, the Symfony/Console component will use the built-in STDIN
PHP constant to capture the input stream. That constant is only available in the CLI environment.
To avoid this error, you need to use the --force
option to disable the interactivity:
Route::get('/queue-clear', function () {
Artisan::call('queue:clear', [
'--force' => true
]);
});