1. Go to this page and download the library: Download pepperfm/filament-json library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pepperfm / filament-json example snippets
use PepperFM\FilamentJson\Columns\JsonColumn;
use PepperFM\FilamentJson\Enums\{RenderModeEnum, ContainerModeEnum};
// Inline (in-cell): always pretty raw JSON with click-to-copy
JsonColumn::make('properties')
->renderAs(RenderModeEnum::Tree) // used if you later switch to modal/drawer
->presentIn(ContainerModeEnum::Inline);
// Tree in a Drawer (with toolbar)
JsonColumn::make('properties')
->renderAs(RenderModeEnum::Tree)
->presentIn(ContainerModeEnum::Drawer)
->initiallyCollapsed(1)
->expandAllToggle() // Tree only (modal/drawer)
->copyJsonAction(false); // hide Copy button
// Table mode in a Modal with custom headers
JsonColumn::make('properties')
->renderAs(RenderModeEnum::Table)
->presentIn(ContainerModeEnum::Modal)
->keyColumnLabel('Custom Key Label')
->valueColumnLabel('Custom Value Label');
use Filament\Support\Enums\Width;
use Filament\Support\Icons\Heroicon;
class ButtonConfigDto extends \Pepperfm\Ssd\BaseDto
{
public string $color = 'primary';
public Heroicon $icon = Heroicon::OutlinedSwatch;
public ?string $label = null;
public ?string $tooltip = null;
public Width $size = Width::Medium;
public ?string $href = null;
public ?string $tag = null;
}
use Filament\Support\Icons\Heroicon;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\Width;
class ModalConfigDto extends \Pepperfm\Ssd\BaseDto
{
public ?string $id = null;
public Heroicon $icon = Heroicon::Sparkles;
public string $iconColor = 'primary';
public Alignment $alignment = Alignment::Start;
public string $width = Width::TwoExtraLarge->value;
public bool $closeByClickingAway = true;
public bool $closedByEscaping = true;
public bool $closedButton = true;
public bool $autofocus = true;
}