PHP code example of inlayphp / infolists

1. Go to this page and download the library: Download inlayphp/infolists 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/ */

    

inlayphp / infolists example snippets


use Inlay\Infolists\Entries\IconEntry;
use Inlay\Infolists\Entries\RepeatableEntry;
use Inlay\Infolists\Entries\TextEntry;
use Inlay\Infolists\Infolist;
use Inlay\Actions\Action;
use Inlay\Schemas\Components\Section;

$details = Infolist::make('user.details')
    ->columns(2)
    ->schema([
        Section::make('profile')->columns(2)->columnSpan(2)->schema([
            TextEntry::make('email')
                ->statePath('contact.email')
                ->copyable(message: 'Email copied')
                ->suffixAction(
                    Action::make('verify-email')
                        ->label('Verify email')
                        ->icon('heroicon-o-check-badge')
                        ->iconButton()
                        ->url(route('users.verify-email', $user)),
                ),
            IconEntry::make('verified')->boolean(),
            TextEntry::make('balance')->money('USD'),
            TextEntry::make('created_at')->date('M j, Y'),
            RepeatableEntry::make('addresses')->columns(2)->schema([
                TextEntry::make('street'),
                TextEntry::make('city'),
            ]),
        ]),
    ])
    ->data($user->toArray());

return inertia('Users/Show', ['userDetails' => $details]);

TextEntry::make('total')
    ->color('success')
    ->size('large')        // extra-small | small | medium | large
    ->weight('semibold')   // thin … black
    ->fontFamily('mono')   // sans | serif | mono
    ->tooltip('Including tax');

IconEntry::make('verified')
    ->boolean()
    ->true(icon: 'shield-check', color: 'success')
    ->false(icon: false, color: 'neutral')
    ->size('lg');

KeyValueEntry::make('metadata')
    ->keyLabel(fn (array $state): string => count($state) === 1 ? 'Attribute' : 'Attributes')
    ->valueLabel('Stored value')
    ->placeholder(fn (): string => 'Nothing recorded');

ImageEntry::make('avatars')
    ->imageWidth('12rem')
    ->imageHeight('8rem')
    ->limit(4)
    ->limitedRemainingText()
    ->limitedRemainingTextSeparate();

use Inlay\Infolists\Entries\ImageEntry;

ImageEntry::make('colleagues.avatar')
    ->imageHeight(48)
    ->circular()
    ->stacked()
    ->ring(3)       // 0–8 pixels
    ->overlap(4)    // 0–8, converted to compact stack spacing
    ->limit(4)
    ->limitedRemainingText(true, true, 'small')
    ->alt('Colleague');

ImageEntry::make('logo')
    ->imageWidth(160)
    ->imageHeight(48)
    ->defaultImageUrl(asset('images/company-placeholder.svg'))
    ->extraImgAttributes([
        'decoding' => 'async',
        'loading' => 'lazy',
        'class' => 'object-contain',
    ]);

ImageEntry::make('avatars')->alt(fn (array $paths): array => array_map(
    fn (string $path): string => basename($path),
    $paths,
));

ImageEntry::make('header_image')
    ->disk('s3')
    ->visibility('public');

ImageEntry::make('attachment')
    ->disk('private-uploads')
    ->checkFileExistence(false); // still generates a temporary URL

use Inlay\Infolists\Entries\CodeEntry;
use Phiki\Grammar\Grammar;
use Phiki\Theme\Theme;

CodeEntry::make('deployment_script')
    ->grammar(Grammar::Shellscript)
    ->lightTheme(Theme::GithubLight)
    ->darkTheme(Theme::GithubDark)
    ->copyable()
    ->copyMessage('Script copied')
    ->copyMessageDuration(1500);

CodeEntry::make('settings')
    ->jsonFlags(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
    ->copyable();

RepeatableEntry::make('contacts')
    ->columns(2)
    ->grid([
        'default' => 1,
        'md' => 2,
        '@xl' => 3,
    ])
    ->contained(false)
    ->schema([
        TextEntry::make('name'),
        TextEntry::make('email'),
    ]);

use Inlay\Infolists\Entries\RepeatableEntry\TableColumn;

RepeatableEntry::make('comments')
    ->table([
        TableColumn::make('Author')->width('12rem'),
        TableColumn::make('Long comment title')
            ->wrapHeader()
            ->alignment('center'),
        TableColumn::make('Published')
            ->hiddenHeaderLabel()
            ->alignment('right'),
    ])
    ->schema([
        TextEntry::make('author.name'),
        TextEntry::make('title'),
        IconEntry::make('is_published')->boolean(),
    ]);

TextEntry::make('created_at')->since('UTC')->sinceTooltip('UTC');
TextEntry::make('notes')->words(20);
TextEntry::make('reference')->wrap(false); // Keep identifiers on one line.
TextEntry::make('published_at')
    ->timezone('Asia/Hong_Kong')
    ->dateTime()
    ->icon('heroicon-o-clock')
    ->iconColor('primary')
    ->iconPosition('after');
TextEntry::make('price')->money('USD', divideBy: 100); // Stored in cents.

TextEntry::make('website')
    ->url(fn (string $state): string => route('users.show', $state))
    ->openUrlInNewTab(fn (string $state): bool => $state === 'external');

TextEntry::make('email')
    ->copyable()
    ->copyableState(fn (string $state): string => strtolower($state))
    ->copyMessage(fn (string $state): string => "Copied {$state}")
    ->copyMessageDuration(fn (string $state): int => str_ends_with($state, '@example.com') ? 3500 : 2000);

use App\Models\Order;
use Inlay\Infolists\Entries\TextEntry;

TextEntry::make('reference')
    ->formatStateUsing(
        fn (mixed $state, string $operation, ?Order $record): string =>
            strtoupper("{$operation}-{$record?->getKey()}-{$state}"),
    );

RepeatableEntry::make('people')->schema([
    TextEntry::make('biography')
        ->markdown()
        ->copyable(),
]);

use Illuminate\Database\Eloquent\Builder;
use Inlay\Infolists\Entries\TextEntry;

$infolist
    ->record($author)
    ->schema([
        TextEntry::make('books_avg_pages')->avg('books', 'pages')->number(1),
        TextEntry::make('books_max_pages')->max('books', 'pages'),
        TextEntry::make('books_min_pages')->min('books', 'pages'),
        TextEntry::make('books_sum_pages')->sum('books', 'pages'),
        TextEntry::make('active_pages')
            ->statePath('stats.active_pages')
            ->sum([
                'books' => fn (Builder $query): Builder => $query->where('active', true),
            ], 'pages'),
    ]);

TextEntry::make('books_avg_pages')
    ->avg(fn (): string => 'books', fn (): string => 'pages');

TextEntry::make('books_count')->counts('books');

TextEntry::make('books_count')->counts([
    'books' => fn (Builder $query): Builder => $query->where('active', true),
]);

TextEntry::make('biography')
    ->markdown()
    ->prose();

TextEntry::make('biography')
    ->markdown()
    ->lineClamp(4)
    ->copyable();

TextEntry::make('roles')
    ->separator('|')
    ->bulleted() // also enables listWithLineBreaks()
    ->limitList(3)
    ->expandableLimitedList();

use Inlay\Actions\Action;
use Inlay\Infolists\Entries\TextEntry;

TextEntry::make('email')
    ->prefixAction(
        Action::make('open-contact')
            ->label('Open contact')
            ->icon('heroicon-o-user')
            ->iconButton()
            ->url('/contacts/42'),
    )
    ->suffixActions([
        Action::make('verify-email')
            ->label('Verify email')
            ->

use Inlay\Actions\Action;
use Inlay\Infolists\Entries\TextEntry;
use Inlay\Schemas\Components\Icon;
use Inlay\Schemas\Components\Text;
use Inlay\Schemas\SchemaContext;

TextEntry::make('email')
    ->aboveLabel('Primary contact')
    ->beforeLabel(Icon::make('heroicon-o-envelope'))
    ->afterLabel(
        Action::make('verify')
            ->label('Verify')
            ->url('/users/42/verify')
            ->method('post'),
    )
    ->belowLabel('Used for recovery and security alerts.')
    ->aboveContent(Text::make('Work email')->weight('semibold'))
    ->beforeContent('Address:')
    ->afterContent(Icon::make('heroicon-o-check-badge')->color('success'))
    ->belowContent(fn (SchemaContext $context): array => [
        $context->get('email_verified_at')
            ? Text::make('Verified')
            : Text::make('Verification pending')->color('warning'),
    ]);