Closed
Description
Laravel Version
11.0.8
PHP Version
8.3
Database Driver & Version
not needed
Description
env:encrypt
command not working when added macro on Illuminate\Console\Scheduling\Event
in AppServiceProvider::boot
method.
Others commands work as expected , but not env:encrypt
.
output :
BadMethodCallException
Method Illuminate\Console\Scheduling\Event::custom does not exist.
at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:112
This command does not load Providers boot method and not load Macros defined inside.
Steps To Reproduce
AppServiceProvider
:
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Event::macro('custom', function() {
return $this
->onOneServer()
->runInBackground();
});
}
providers.php
:
return [
App\Providers\AppServiceProvider::class,
];
console.php
:
// use macro
Schedule::command('sanctum:prune-expired --hours=24')->daily()->custom();
launch command :
php artisan env:encrypt --help