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

env:encrypt command not working when added macro on Illuminate\Console\Scheduling\Event in AppServiceProvider::boot method #50716

Closed
pecqueurS opened this issue Mar 22, 2024 · 1 comment · Fixed by #50738

Comments

@pecqueurS
Copy link

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
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

taylorotwell pushed a commit that referenced this issue Mar 25, 2024
…ooted (#50716) (#50738)

Co-authored-by: Kacper Pruszynski <kacper@telgani.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants