In my laravel app, I want to schedule some tasks using the scheduler. In order not to duplicate code, I want to re-use functionality already in some of my Modules. I specifically made one CronModule
, that uses some of the other modules for it's job. In my app/Console/Kernel.php
I have this for the schedule function:
protected function schedule(Schedule $schedule)
{
$cronmodule = $this->app->make('App\Dashboard\Modules\CronModule');
$schedule->call(function () {
echo "======yes";
})->everyMinute();
}
The problem that I run into, is that some of my other modules make use of the Illuminate\Support\Facades\Auth
Facade, which is aliased in config\app.php to "Auth". I don't actually need the Auth facade to work for any of the functions called by my CronModule. Of course that wouldn't make sense in the scope of CronJobs. But I think the modules for some reason can't find that Facade already when importing it, and so running php artisan schedule:run
errors out with
[ErrorException]
Use of undefined constant Auth - assumed 'Auth' (this will throw an Error in a future version of PHP)