Installation:
composer require tomatophp/filament-artisan
Register the plugin in app/Providers/Filament/AdminPanelProvider.php:
->plugin(\TomatoPHP\FilamentArtisan\FilamentArtisanPlugin::make())
First Use Case:
/filament/artisan (or your Filament panel URL with /artisan appended).migrate, optimize:clear, filament:install).config/filament-artisan.php for environment restrictions (default: local only)./artisan page lists all available commands with their signatures.Running Standard Commands:
db:wipe, filament:make).--force for destructive commands).Custom Command Integration:
php artisan vendor:publish --provider="TomatoPHP\FilamentArtisan\FilamentArtisanServiceProvider"
config/filament-artisan.php under commands:
'commands' => [
'your:custom-command' => [
'description' => 'Run a custom task',
'arguments' => [
['name' => 'param', 'description' => 'Input parameter'],
],
],
],
app/Console/Kernel.php:
protected $commands = [
\YourNamespace\Commands\YourCustomCommand::class,
];
Environment-Specific Access:
config/filament-artisan.php to allow commands in non-local environments:
'environments' => ['local', 'staging'], // Add 'production' cautiously!
Bulk Operations:
&& in the input field (e.g., migrate && optimize).db:wipe).\TomatoPHP\FilamentArtisan\FilamentArtisanPlugin::make()
->outputHandler(function ($output) {
\Log::info('Artisan Command Output:', ['output' => $output]);
}),
Environment Restrictions:
local only. Forgetting to update config/filament-artisan.php can lock you out of running commands in other environments.'environments' => ['local', 'staging'],
Command Arguments:
make:model) may fail silently.Output Parsing:
->outputHandler(function ($output) {
return preg_replace('/\x1B\[([0-9A-Za-z])*[mGK]?/', '', $output);
}),
Destructive Commands:
db:wipe or cache:clear can break production.Command Not Showing?:
app/Console/Kernel.php.config/filament-artisan.php under commands.hidden() in the command class).Blank Output:
php artisan view:clear
Custom UI:
php artisan vendor:publish --tag=filament-artisan-views
resources/views/vendor/filament-artisan/ to add custom fields or validation.Pre/Post Hooks:
\TomatoPHP\FilamentArtisan\FilamentArtisanPlugin::make()
->beforeRun(function ($command) {
\Log::info("Running command: {$command}");
})
->afterRun(function ($output, $exitCode) {
if ($exitCode !== 0) {
\Toast::danger("Command failed with exit code {$exitCode}");
}
}),
API Access:
// In a Filament resource or page
use TomatoPHP\FilamentArtisan\Facades\ArtisanRunner;
public function runCommand()
{
$output = ArtisanRunner::run('migrate');
return response()->json(['output' => $output]);
}
/artisan page for quick access to frequent commands.--dry-run flag for destructive commands (if supported) to preview changes.->afterRun(function ($output, $exitCode) {
\App\Models\ArtisanLog::create([
'command' => request('command'),
'output' => $output,
'exit_code' => $exitCode,
'user_id' => auth()->id(),
]);
}),
How can I help you explore Laravel packages today?