Calling pennant:purge command via Artisan::call() keeps failing
stephenjude opened this issue · comments
Stephen Jude commented
Pennant Version
1.5
Laravel Version
10.31.0
PHP Version
8.1.15
Database Driver & Version
MySQL 8.0.32
Description
Calling pennant:purge command via Artisan::call() keeps failing when done outside the terminal.
Like calling it inside a queue job class.
I believe this is because the console commands are registered to only run when the application is running in console.
if ($this->app->runningInConsole()) {
$this->offerPublishing();
$this->commands([
\Laravel\Pennant\Commands\FeatureMakeCommand::class,
\Laravel\Pennant\Commands\PurgeCommand::class,
]);
}
Can we have this check removed so the command can be run from anywhere in the application?
Steps To Reproduce
Create a job class and call the the pennant:purge
command inside the handle()
method like this:
public function handle(): void
{
Artisan::call('pennant:purge');
}
Mior Muhammad Zaki commented
You should be able to just do the following:
use Laravel\Pennant\FeatureManager;
app(FeatureManager::class)->store()->purge();
Stephen Jude commented
Thank you @crynobone