Skip to content

Instantly share code, notes, and snippets.

@CharlieEtienne
Last active June 20, 2025 16:32
Show Gist options
  • Save CharlieEtienne/3418f407ec4af40c6de3ee0ae27c4623 to your computer and use it in GitHub Desktop.
Save CharlieEtienne/3418f407ec4af40c6de3ee0ae27c4623 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Temporary Artisan command runner
TMP_FILE="app/Console/Commands/__TempCheckFilamentCompat.php"
# Check if it's already installed
if [ ! -f artisan ]; then
echo "❌ This is not a Laravel project (no artisan file found)."
exit 1
fi
# Write the temporary command
cat > $TMP_FILE <<'PHP'
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
class __TempCheckFilamentCompat extends Command
{
protected $signature = 'temp:check-filament-compat';
protected $description = 'Check Filament plugins for v4 compatibility';
public function handle()
{
$composer = json_decode(file_get_contents(base_path('composer.json')), true);
$deps = $composer['require'] ?? [];
$plugins = collect($deps)->keys();
$this->info("πŸ“¦ Checking Filament plugin compatibility with v4\n");
$this->table(
['Package', 'Installed', 'v4 Compatible?', 'Latest v4 Version'],
$plugins->map(function ($pkg) use ($deps) {
$compat = $this->checkV4($pkg);
return [
$pkg,
$deps[$pkg],
$compat ? 'βœ…' : '❌',
$compat ?: '–',
];
})
);
unlink(__FILE__); // Clean up after running
}
protected function checkV4(string $pkg): ?string
{
$res = @file_get_contents("https://repo.packagist.org/p2/{$pkg}.json");
if (!$res) return null;
$data = json_decode($res, true);
foreach ($data['packages'][$pkg] ?? [] as $v) {
$req = $v['require']['filament/filament'] ?? null;
if ($req && preg_match('/\^4\.|~4\.|>=4\./', $req)) {
return $v['version'];
}
}
return null;
}
}
PHP
# Run the command
php artisan temp:check-filament-compat
# Remove the temp command file
[ -f "$TMP_FILE" ] && rm "$TMP_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment