PHPackages                             wertelko/easyadmin-content-bundle - 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. [Admin Panels](/categories/admin)
4. /
5. wertelko/easyadmin-content-bundle

ActiveBundle[Admin Panels](/categories/admin)

wertelko/easyadmin-content-bundle
=================================

Simple bundle that allows displaying content in the EasyAdmin

1.0.7(3mo ago)16MITPHP

Since Feb 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/wertelko/EasyadminContentBundle)[ Packagist](https://packagist.org/packages/wertelko/easyadmin-content-bundle)[ RSS](/packages/wertelko-easyadmin-content-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (9)Used By (0)

### EasyadminContentBundle Documentation

[](#easyadmincontentbundle-documentation)

This document provides an overview of the `EasyadminContentBundle` and instructions on how to use its core components to build content programmatically.

[![EasyadminContentBundle](docs/images/easyadmin-content.png)](docs/images/easyadmin-content.png)

#### 0. Instalation

[](#0-instalation)

```
composer require wertelko/easyadmin-content-bundle

```

#### 1. Introduction

[](#1-introduction)

The `EasyadminContentBundle` is designed to simplify the creation of structured content blocks within your Symfony controllers. Instead of writing raw HTML or complex logic in your Twig templates, you can use a fluent, object-oriented API to define content elements like headings, lists, tables, and forms.

This is particularly useful for building admin dashboards, reports, or any page where the structure is defined by the backend logic.

#### 2. Core Concepts

[](#2-core-concepts)

The bundle is built around the concept of `Content` objects. Each type of content (e.g., a heading or a table) is represented by a specific class that extends the base `Content` class.

- **`Content` class**: The base class for all content blocks. It holds a `ContentDto` which carries the data and rendering options to the template.
- **`ContentDto`**: A Data Transfer Object that stores the content itself, the path to the Twig template for rendering, and other display options.
- **Static Factory `new()`**: All content classes have a static factory method `new()` for cleaner, more readable instantiation.

#### 3. Content Types

[](#3-content-types)

The bundle provides several predefined content types.

##### 3.1. `HeadingContent`

[](#31-headingcontent)

Used to create HTML heading elements (`` to ``).

- **Class**: `HeadingContent`
- **Usage**: Create an instance with the heading text and then use a fluent method to set the heading level.

```
use Wertelko\EasyadminContentBundle\Content\HeadingContent;

// Creates an  element
$heading = HeadingContent::new('My Page Title')->asH2();
```

- **Methods**: `asH1()`, `asH2()`, `asH3()`, `asH4()`, `asH5()`, `asH6()`.

##### 3.2. `ListContent`

[](#32-listcontent)

Used to render an unordered (``) or ordered (``) list.

- **Class**: `ListContent`
- **Usage**: Pass an array of items to the constructor. By default, it creates a ``.

```
use Wertelko\EasyadminContentBundle\Content\ListContent;

// Creates a  list
$list = ListContent::new(['First item', 'Second item', 'Third item']);

// Creates an  list
$orderedList = ListContent::new(['Step 1', 'Step 2'])->asOrdered();
```

- **Methods**: `asUnordered()` ( default), `asOrdered()`.

##### 3.3. `TableContent`

[](#33-tablecontent)

Used to render a data table.

- **Class**: `TableContent`
- **Usage**: Pass an array of associative arrays. The keys of the first item are used as table headers by default.

```
use Wertelko\EasyadminContentBundle\Content\TableContent;

$data = [
    ['id' => 1, 'name' => 'Product A', 'price' => 100],
    ['id' => 2, 'name' => 'Product B', 'price' => 150],
];

// Creates a table with headers 'id', 'name', 'price'
$table = TableContent::new($data);

// Creates a table without headers
$tableNoHeaders = TableContent::new($data)
    ->setHeaders(['Product ID', 'Product', 'Price']) // Set custom headers
    ->hideCounter() // Hide result counter
    ->hideHeaders(); // Hide headers
```

- **Methods**:
    - `setHeaders(array $headers)`: Sets custom headers for the table columns.
    - `hideHeaders(bool $hidden = true)`: Hides the table header row.
    - `hideCounter(bool $hidden = true)`: Hides the results counter (e.g., "50 results").

##### 3.4. `FormContent`

[](#34-formcontent)

Used to render a Symfony Form.

- **Class**: `FormContent`
- **Usage**: Pass a `FormView` or a `Form` object to its constructor. It will automatically create the `FormView` if needed.

```
use Wertelko\EasyadminContentBundle\Content\FormContent;

// Assuming $form is a Symfony Form object created in your controller
$formContent = FormContent::new($form);
```

#### 4. Customizing Content

[](#4-customizing-content)

All content objects inherit from the base `Content`class, giving you access to powerful customization methods.

##### 4.1. Overriding Templates with `setTemplate()`

[](#41-overriding-templates-with-settemplate)

Every content block is rendered using a default Twig template. The `setTemplate()` method allows you to specify a different template path for any content object, giving you full control over its HTML output.

- **Usage**: ```
    use Wertelko\EasyadminContentBundle\Content\ListContent;

    // Render this list using a custom Twig template
    $list = ListContent::new(['item 1', 'item 2'])
        ->setTemplate('partials/custom_bootstrap_list.html.twig');
    ```

##### 4.2. Passing Custom Data with `setOption()`

[](#42-passing-custom-data-with-setoption)

The `setOption()` method provides a flexible way to pass custom data, flags, or configuration from your controller to your Twig templates. This is ideal for adding CSS classes, element IDs, or other display-related attributes.

- **Usage**:

    ```
    use Wertelko\EasyadminContentBundle\Content\TableContent;

    // Pass a custom CSS class to the table template
    $table = TableContent::new($data)
        ->setOption('table_id', 'my-table-id');
    ```
- **In your Twig template**, you can then access this option:

    ```
    {# Retrieve the option with a default fallback value #}

        {# ... table content ... #}

    ```

---

### Implementation Plan

[](#implementation-plan)

Here is a plan to demonstrate the usage of your bundle with a complete example.

1. **Create a simple Form Type**: We'll create a `TaskType.php` to demonstrate the `FormContent`.
2. **Create the `TestController`**: This controller will build a page using all the different content types (`Heading`, `List`, `Table`, and `Form`).

### Step 1: Create a Form Type

[](#step-1-create-a-form-type)

This is a standard Symfony form type that we will use in our controller example.

```
add('name', TextType::class, [
                'label' => 'Task Name',
                'attr' => ['placeholder' => 'Enter the task name...']
            ])
            ->add('save', SubmitType::class, [
                'label' => 'Create Task'
            ]);
    }
}
```

### Step 2: Create the `TestController`

[](#step-2-create-the-testcontroller)

This controller demonstrates how to instantiate and combine different content blocks to build a complete page. This controller should implements `EasyadminContentControllerInterface` and use `EasyAdminContentTrait`

```
asH1();

        // 2. Add a subheading and an ordered list
        $contents[] = HeadingContent::new('Features')->asH2();
        $contents[] = ListContent::new([
            'Object-oriented content blocks',
            'Fluent interface',
            'Separation of concerns',
        ])->asOrdered();

        // 3. Add a table of data
        $contents[] = HeadingContent::new('Sample Data Table')->asH2();
        $tableData = [
            ['id' => 1, 'product' => 'Laptop', 'stock' => 15],
            ['id' => 2, 'product' => 'Mouse', 'stock' => 120],
            ['id' => 3, 'product' => 'Keyboard', 'stock' => 75],
        ];
        $contents[] = TableContent::new($tableData)
            ->setHeaders(['Product ID', 'Product', 'Price']);

        // 4. Add a Symfony form
        $contents[] = HeadingContent::new('Sample Form')->asH2();
        $form = $formFactory->create(TaskType::class);
        $contents[] = FormContent::new($form);

        return $this->renderContent($contents, 'Test page title');
    }
}
```

---

### Important Note: Usage within the EasyAdmin Context

[](#important-note-usage-within-the-easyadmin-context)

This bundle is designed specifically to work inside **EasyAdmin**. The rendering mechanism, particularly the `renderContent` method from the `EasyAdminContentTrait`, is tightly coupled with the EasyAdmin architecture and context.

Attempting to use `renderContent` in a standard Symfony controller outside of the EasyAdmin environment will not work, as the bundle relies on specific services and context variables that EasyAdmin provides during request processing.

For the bundle to function correctly, all controllers implementing `EasyadminContentControllerInterface` must be accessed through EasyAdmin's routing system. For example: `http://localhost:8000/admin?routeName=app_test`.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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 ~6 days

Total

8

Last Release

98d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d8419959df5fae3e2e65bbaf5689891bf1a2206948bdd57258ac3268d80dfff?d=identicon)[wertelko](/maintainers/wertelko)

---

Top Contributors

[![example123](https://avatars.githubusercontent.com/u/87628?v=4)](https://github.com/example123 "example123 (14 commits)")

---

Tags

symfonycontenteasyadmin

### Embed Badge

![Health badge](/badges/wertelko-easyadmin-content-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/wertelko-easyadmin-content-bundle/health.svg)](https://phpackages.com/packages/wertelko-easyadmin-content-bundle)
```

###  Alternatives

[umanit/easyadmin-tree-bundle

Plugin to add category tree features for EasyAdmin

237.3k](/packages/umanit-easyadmin-tree-bundle)[agence-adeliom/easy-fields-bundle

A Symfony bundle for EasyAdmin that provide some fields

1317.8k9](/packages/agence-adeliom-easy-fields-bundle)[wandi/easyadmin-plus-bundle

Wandi/EasyAdminPlusBundle

3926.2k](/packages/wandi-easyadmin-plus-bundle)[2lenet/easyadmin-plus-bundle

2lenet/EasyAdminPlusBundle

1818.1k](/packages/2lenet-easyadmin-plus-bundle)[artgris/page-bundle

add a page manager to EasyAdminBundle for Symfony

151.5k](/packages/artgris-page-bundle)

PHPackages © 2026

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