PHPackages                             edsi-tech/sir-trevor-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. edsi-tech/sir-trevor-bundle

ActiveSymfony-bundle

edsi-tech/sir-trevor-bundle
===========================

Bundle integrating SirTrevor library

0.5.3(11y ago)131142[4 issues](https://github.com/EDSI-Tech/SirTrevorBundle/issues)MITCSSPHP ~5.4

Since Nov 12Pushed 11y ago2 watchersCompare

[ Source](https://github.com/EDSI-Tech/SirTrevorBundle)[ Packagist](https://packagist.org/packages/edsi-tech/sir-trevor-bundle)[ RSS](/packages/edsi-tech-sir-trevor-bundle/feed)WikiDiscussions master Synced 1mo ago

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

SirTrevor Bundle *by EDSI-Tech Sarl*
====================================

[](#sirtrevor-bundle-by-edsi-tech-sarl)

Integration of [SirTrevor](https://github.com/madebymany/sir-trevor-js) JS library into a Symfony2 bundle.

SirTrevor editor works with "blocks", fragment of content of different types. This bundle allow you to map those to Doctrine entities. Secondly, it provides a TwigExtension &amp; templates to easily achieve a clean SirTrevor integration.

[![SensioLabsInsight](https://camo.githubusercontent.com/5cf901fac4a54f6aa3140de98bc1f614a733b65522b15c242ebde3fa7c78f1e3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33366634316361342d343531372d343163382d396336392d6430653333373637333264362f6269672e706e67)](https://insight.sensiolabs.com/projects/36f41ca4-4517-41c8-9c69-d0e3376732d6)

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

[](#installation)

Using packing, require `edsi-tech/sir-trevor-bundle`Then register it in `app/AppKernel.php`.

Usage
-----

[](#usage)

### Model

[](#model)

You must extend `EdsiTech\SirTrevorBundle\Entity\AbstractBlock`. `AbstractBlock` represent a block as SirTrevor knows it. It can be easily mapped to a Doctrine ORM entity, for this for already put some annotations.

### Rendering the editor

[](#rendering-the-editor)

To render the editor, put in a Twig template:

```
{{ cms_render(blocks) }}
```

You must pass to this template a `blocks` variable , containing a collection of `AbstractBlock`. Moreover, using a `is_editable` variable, you can decide whether to render a content editable with SirTrevor or just to render the blocks as plain old HTML.

By default we use the theme `EdsiTechSirTrevorBundle:Render:_blocks_theme.html.twig`.
You can change it via Bundle config:

```
# app/config/config.yml
edsi_tech_sir_trevor:
    edsi_tech_sir_trevor: 'EdsiTechSirTrevorBundle:Render:_blocks_theme.html.twig'
```

### Saving blocks

[](#saving-blocks)

Blocks will be re-send to your controller, via POST. To handle those, you should use the provided `edsi_tech_sir_trevor.handler.block_handler` service. It will read the Request and return you an array of `EdsiTech\SirTrevorBundle\Model\EditedBlock`.

Bonus
-----

[](#bonus)

### Loading Bar

[](#loading-bar)

It includes a progress bar for editor loading. Available using [Pace](http://github.hubspot.com/pace/).

### Flash messages

[](#flash-messages)

Request flash messages are displayed as nice messages powered by [HubSport Messenger](https://github.com/HubSpot/messenger)

Controller example:

```
    public function renderAction()
    {
        $this->get('session')->getFlashBag()->add('success', 'Green success message');
        $this->get('session')->getFlashBag()->add('danger', 'Red danger message');
        $this->get('session')->getFlashBag()->add('info', 'Blue information message');

        return $this->render('myTwigTemplate', [
            'blocks'        => [] // an array of AbstractBlocks
            'is_editable'   => true
        ]);
    }
```

### "back" button

[](#back-button)

The bar on top added by this bundle can include a "back" button. Just provide the URL it should point to in your controller:

```
    public function renderAction()
    {
        return $this->render('myTwigTemplate', [
            'back_link'     => '/',
            'blocks'        => [] // an array of AbstractBlocks
            'is_editable'   => true
        ]);
    }
```

### Even more buttons

[](#even-more-buttons)

You can provide more buttons/HTML to add to the bar on top of the page via `save_bar_buttons`:

```
    public function renderAction()
    {
        return $this->render('myTwigTemplate', [
            'save_bar_buttons' => 'Sir Trevor doc',
            'blocks'        => [] // an array of AbstractBlocks
            'is_editable'   => true
        ]);
    }
```

Full working example
--------------------

[](#full-working-example)

The controller:

```
    public function renderAction()
    {
        if ($request->isMethod('post')) {
            $data = $this->get('my_city_rendering.handler.block_handler')->handle($request);

            // do what you want!

            $this->get('session')->getFlashBag()->add('success', 'Content saved!');
        }

        return $this->render('myTwigTemplate', [
            'back_link'     => '/',
            'blocks'        => [] // an array of AbstractBlocks
            'is_editable'   => true,
            'save_bar_buttons` => 'Sir Trevor doc',
        ]);
    }
```

The template:

```

        SirTrevor example

        Some content that won't be editable by SirTrevor
        {{ cms_render(blocks) }}

```

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

[](#configuration)

### Allowed blocks

[](#allowed-blocks)

By defaults not all SirTrevor blocks are enabled, you can modify it in bundle configuration:

```
# app/config/config.yml
edsi_tech_sir_trevor:
    allowed_blocks:
        # below are blocks enabled by default
        # you can remove one of course!
        - Heading
        - Text
        - List
        - Quote
        # and I also want to add SirTrevor Image & Video blocks (watch out file upload are not handled at the moment)
        - Image
        - Video
        - Tweet
```

### Themes

[](#themes)

When the content is rendered, we are using a `blocks_theme` to determine the HTML for each block *(in a manner pretty similar to Symfony2 Form theme)*. A default implementation is included; if you want to customize it, you can set your own Twig template in configuration.

All blocks are rendered within a `render_template` you can also override.

```
# app/config/config.yml
edsi_tech_sir_trevor:
    blocks_theme: EdsiTechSirTrevorBundle:Render:_blocks_theme.html.twig
    render_template: EdsiTechSirTrevorBundle:Render:base.html.twig
```

### Adding an extra CSS or JS file

[](#adding-an-extra-css-or-js-file)

You can inject another JS file, loaded after included JS libraries but before the editor is initialized. A common use case is to add some SirTrevor blocks.

In the same manner, you can also add a CSS file, that will be included after all ours stylesheets.

```
# app/config/config.yml
edsi_tech_sir_trevor:
    allowed_blocks:
        - Text
        - Heading
        - Custom # tip: do not forget to enable your custom block!
    extra_js_file: 'bundles/acmedemo/js/custom-block.js'
    extra_css_file: 'bundles/acmedemo/css/style.css'
```

Going further
-------------

[](#going-further)

### Getting Editor instance

[](#getting-editor-instance)

You can retrieve the SirTrevor instance in JS by doing `SirTrevor.getInstance()`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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 ~3 days

Total

11

Last Release

4163d ago

### Community

Maintainers

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

---

Top Contributors

[![romaricdrigon](https://avatars.githubusercontent.com/u/919405?v=4)](https://github.com/romaricdrigon "romaricdrigon (55 commits)")[![flvndvd](https://avatars.githubusercontent.com/u/7428970?v=4)](https://github.com/flvndvd "flvndvd (1 commits)")

### Embed Badge

![Health badge](/badges/edsi-tech-sir-trevor-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/edsi-tech-sir-trevor-bundle/health.svg)](https://phpackages.com/packages/edsi-tech-sir-trevor-bundle)
```

###  Alternatives

[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[innomatic/innomatic-platform

Innomatic Platform distribution

352.2k](/packages/innomatic-innomatic-platform)[anime-db/anime-db

The application for making home collection anime

252.1k2](/packages/anime-db-anime-db)[leaphly/leaphly-sandbox

The Leaphly sandbox

144.4k](/packages/leaphly-leaphly-sandbox)

PHPackages © 2026

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