PHPackages                             pvtl/dynamic-content - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pvtl/dynamic-content

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pvtl/dynamic-content
====================

Dynamic content management with configurable sections for Laravel Livewire and Flux UI applications

1.0.4(2w ago)042↓80%MITPHPPHP ^8.4CI passing

Since Jun 10Pushed 5d agoCompare

[ Source](https://github.com/pvtl/dynamic-content)[ Packagist](https://packagist.org/packages/pvtl/dynamic-content)[ RSS](/packages/pvtl-dynamic-content/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (10)Versions (6)Used By (0)

pvtl/dynamic-content
====================

[](#pvtldynamic-content)

Dynamic content management with configurable sections for Laravel Livewire and Flux UI applications. Define section types in a config file, manage content through an admin UI, and render sections on the frontend using Blade components.

Requirements
------------

[](#requirements)

- PHP ^8.4
- Laravel ^13.0
- Livewire ^4.0
- Flux UI ^2.0 (Pro)

Installation
------------

[](#installation)

```
composer require pvtl/dynamic-content
```

Publish resources and run migrations:

```
php artisan pvtl-dynamic-content:publish
php artisan migrate
```

What Gets Published
-------------------

[](#what-gets-published)

`pvtl-dynamic-content:publish` installs:

ResourceDestinationMigrations`database/migrations/`Package config`config/dynamic_content.php`Routes`routes/dynamic_content.php`Sections config stub`config/sections.php`To also publish the section field Blade components for customisation:

```
php artisan pvtl-dynamic-content:publish-sections
```

This copies the field input components to `resources/views/components/sections/`. Once published, the package uses your copies instead of its own defaults.

Configuration
-------------

[](#configuration)

### `config/dynamic_content.php`

[](#configdynamic_contentphp)

```
return [
    // Filesystem disk for section image/file uploads.
    'disk' => env('DYNAMIC_CONTENT_DISK', 'public'),

    // Blade component directory for frontend section renderers.
    // 'dynamic' resolves a section component named 'homepage-hero'
    // to .
    'component_directory' => env('DYNAMIC_CONTENT_COMPONENT_DIR', 'dynamic'),
];
```

### Routes

[](#routes)

The published `routes/dynamic_content.php` contains the admin CRUD routes. Customise them as needed — add middleware, change URIs, or wrap them in a route group to suit your application's auth setup.

Helpers
-------

[](#helpers)

The package ships a global helpers file (`src/helpers.php`, autoloaded via Composer) with small utility functions for working with stored field values in your frontend section components:

- `dcGetFileUrl(?string $file): ?string` — Resolves a stored file path (from an `ImageUpload` or `DownloadableFile` field) to a public URL using the configured `dynamic_content.disk`, or `null` if no file is set.

Defining Sections
-----------------

[](#defining-sections)

Edit the published `config/sections.php` to define the section types available in the admin panel. The `homepage-hero` example is included and ready to use:

```
use Pvtl\DynamicContent\Enums\SectionFieldType;

return [
    [
        'slug'        => 'homepage-hero',
        'component'   => 'homepage-hero',
        'description' => 'Hero banner displayed at the top of the homepage.',
        'fields'      => [
            [
                'name'       => 'Heading',
                'slug'       => 'heading',
                'description'=> 'Main headline text.',
                'type'       => SectionFieldType::Text,
                'class'      => 'w-1/2',
                'default'    => '',
                'validation' => ['required', 'string', 'max:255'],
                'options'    => [],
            ],
            // ...more fields
        ],
    ],
];
```

Refer to the schema comment at the top of `config/sections.php` for the full list of available field types and options.

### Dynamic (database-backed) options

[](#dynamic-database-backed-options)

For `Select`, `Multiselect`, `RadioButton`, and `CheckboxGroup` fields, `options` is normally a static `value => label` array. If you need the list to come from the database (e.g. a dropdown of `Meal` records), you **cannot** just query the database directly inside `config/sections.php`:

```
// ❌ Don't do this — crashes the app.
'options' => \App\Models\Meal::all()->mapWithKeys(fn ($meal) => [$meal->id => $meal->name]),
```

Config files are `require`d by Laravel's `LoadConfiguration` bootstrapper very early in the request lifecycle — **before any service providers (including the database provider) have booted**. Querying the database at this point fails, and Laravel's own attempt to render that error also fails (the `view` binding isn't registered yet either), which surfaces as a confusing `Target class [view] does not exist` error instead of the real cause.

Instead, set `options` to a **static callable array** — `[Class::class, 'method']` — pointing at a method that returns the options. It's resolved lazily, only when the field is actually rendered:

```
// app/Models/Meal.php
public static function dynamicContentOptions(): array
{
    return static::query()->orderBy('name')->pluck('name', 'id')->all();
}
```

```
// config/sections.php
[
    'name'       => 'Featured Meal',
    'slug'       => 'featured_meal',
    'description'=> 'Meal to highlight in this section.',
    'type'       => SectionFieldType::Select,
    'class'      => 'w-1/2',
    'default'    => null,
    'validation' => ['nullable'],
    'options'    => [\App\Models\Meal::class, 'dynamicContentOptions'],
],
```

**Do not use a `Closure`** for this (e.g. `fn () => Meal::all()->pluck(...)`) — closures cannot be serialized by `php artisan config:cache` and will break config caching for the entire application. A `[Class::class, 'method']` array is just two strings, so it caches fine and is resolved with `call_user_func()` only when needed.

Creating Frontend Section Components
------------------------------------

[](#creating-frontend-section-components)

Each section type needs a Blade component that renders it on the frontend. Components live in `resources/views/components/{component_directory}/` (default: `resources/views/components/dynamic/`).

### How it works

[](#how-it-works)

When the `DynamicContentRenderer` outputs a section, it calls:

```

```

Your component receives all stored field values as the `$attrs` array. **Components must never query the database** — all data is passed via `$attrs`.

### Example: `homepage-hero`

[](#example-homepage-hero)

Create `resources/views/components/dynamic/homepage-hero.blade.php`:

```
@props(['attrs' => []])

@php
    $heading    = $attrs['heading'] ?? null;
    $body       = $attrs['body'] ?? null;
    $layout     = $attrs['layout'] ?? 'left';
    $bgImage    = $attrs['background_image'] ?? null;
    $highlights = $attrs['highlights'] ?? [];

    $alignClass = match ($layout) {
        'center' => 'text-center items-center',
        'right'  => 'text-right items-end',
        default  => 'text-left items-start',
    };

    $imageUrl = dcGetFileUrl($bgImage);
@endphp

    @if ($imageUrl)

    @endif

            @if ($heading)

                    {{ $heading }}

            @endif

            @if ($body)
                {!! $body !!}
            @endif

        @forelse($highlights as $highlight)
            @if ($highlight['image'])

            @endif

            @if($highlight['description'])
                {!! $highlight['description'] !!}
            @endif
        @empty
            Nothing here
        @endforelse

```

### Key rules for section components

[](#key-rules-for-section-components)

- Always declare `@props(['attrs' => []])`.
- Access fields via `$attrs['field_slug']` — use `?? null` for optional fields.

Rendering Dynamic Content
-------------------------

[](#rendering-dynamic-content)

Use `DynamicContentRenderer` anywhere in your Blade views:

```

```

The component loads the `DynamicContent` record by slug (creating it if it does not exist), loops through its sections ordered by the `order` column, and renders each one using its configured Blade component.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance98

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

5

Last Release

18d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b54f3e43a9171099a685589c94f7cd35da4da8e600d5737536d14918d872ca56?d=identicon)[pvtl](/maintainers/pvtl)

---

Top Contributors

[![dmytroHud](https://avatars.githubusercontent.com/u/47352448?v=4)](https://github.com/dmytroHud "dmytroHud (9 commits)")

### Embed Badge

![Health badge](/badges/pvtl-dynamic-content/health.svg)

```
[![Health](https://phpackages.com/badges/pvtl-dynamic-content/health.svg)](https://phpackages.com/packages/pvtl-dynamic-content)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M247](/packages/laravel-ai)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
