filament/support
Core support utilities for Filament packages and plugins. Provides shared helpers, contracts, traits, and internal tooling used across the Filament ecosystem to streamline development, ensure consistency, and reduce duplicated code in Laravel apps.
Installation Add the package via Composer (typically installed as a dependency of other Filament packages):
composer require filament/support
No standalone configuration is required—it’s a utility package designed to be consumed by other Filament packages (e.g., filament/filament, filament/forms).
First Use Case
str()->slug(), str()->headline(), or str()->studly() for string manipulation.Filament\Support\Contracts\HasTable or Filament\Support\Enums\Action for custom logic.Filament\Support\Testing\TestCase as a base for package tests.Example:
use Filament\Support\Facades\Filament;
// Generate a slug from a string
$slug = str()->slug('Hello World');
// Check if Filament is installed
if (Filament::isInstalled()) {
// Proceed with Filament-specific logic
}
Where to Look First
src/ for core utilities (e.g., src/Concerns/HasTable.php, src/Enums/).filament/forms) use this package for patterns.str() helpers for consistent formatting (slugs, headlines, etc.).
$title = str()->headline('user_profile'); // "User Profile"
arr() or collect() for nested data transformations.
$data = arr()->set($request->all(), 'user.name', 'John Doe');
HasTable, HasPages, or HasWidgets for custom resources/pages.
use Filament\Support\Contracts\HasTable;
class CustomResource extends Resource implements HasTable {
// ...
}
Action or Notification enums for type-safe operations.
use Filament\Support\Enums\Action;
if ($action === Action::Create) {
// Handle create logic
}
Filament\Support\Testing\TestCase for Filament-specific assertions.
use Filament\Support\Testing\TestCase;
class MyTest extends TestCase {
public function test_something() {
$this->assertFilamentRouteExists('/admin');
}
}
Filament::fake() to simulate Filament services in tests.filament/forms or filament/tables alongside this package for shared utilities.
use Filament\Support\Facades\Filament;
Filament::registerResource(CustomResource::class);
HasWidgets for custom dashboard widgets.Filament, Notifiable, or Action.
use Filament\Support\Facades\Filament;
$user = Filament::auth()->user();
config/filament.php (if used by dependent packages).No Standalone Usage
Version Compatibility
filament/support:v3 for Filament 3.x). Mixing versions may break functionality.Overriding Core Classes
Filament\Support\Contracts or Filament\Support\Enums unless extending for custom logic. Changes may conflict with dependent packages.Testing Quirks
Filament::fake() must be called before assertions in tests. Forgetting this can cause tests to fail silently.Enable Debugging
Set FILAMENT_DEBUG=true in .env to log detailed errors from Filament utilities.
Check Dependent Packages
If a helper method fails, verify it’s not a proxy for another package (e.g., str()->slug() might rely on spatie/array-to-xml).
Facades and Service Providers
If a facade (e.g., Filament) isn’t available, ensure the service provider is registered in config/app.php:
Filament\Support\FilamentServiceProvider::class,
Custom Helpers
Extend the str(), arr(), or collect() helpers by publishing the package’s config (if supported) or creating a macro:
str()->macro('customMethod', fn ($value) => strtolower($value));
New Contracts/Enums
Create custom enums by extending Filament\Support\Enums\Enum:
use Filament\Support\Enums\Enum;
class CustomStatus extends Enum {
public const Pending = 'pending';
public const Approved = 'approved';
}
Testing Utilities
Extend TestCase for reusable test logic:
class CustomTestCase extends TestCase {
protected function setUp(): void {
parent::setUp();
$this->withoutExceptionHandling();
}
}
Configuration Overrides Publish the package’s config (if available) to modify defaults:
php artisan vendor:publish --provider="Filament\Support\FilamentServiceProvider"
Filament services) where possible to reduce overhead.Filament::auth()) may trigger eager loading—cache results if used frequently.How can I help you explore Laravel packages today?