This package is abandoned and no longer maintained. No replacement package was suggested.

MBSecureDisplayBundle is a small simple bundle which protect emails and phone numbers behine encryption and JavaScript

Installs: 218

Dependents: 0

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0


v1.1 2016-07-05 10:33 UTC


MBSecureDisplayBundle is a small simple bundle which protect emails, phone numbers and any text you want from spam bot, by using encryption, ajax and JavaScript.

SensioLabsInsight Build Status


Before installing this bundle, you need to have a working installation of FOSJsRoutingBundle.


Step 1: Composer

First you need to add mb/secure-display-bundle to composer.json:

   "require": {
        "mb/secure-display-bundle": "dev-master"

note: replace dev-master with the last version of this bundle.

Step 2: AppKernel

Register the bundle into the Symfony AppKernel

// app/AppKernel.php

class AppKernel extends Kernel
    public function registerBundles()
        $bundles = array(
            new MB\SecureDisplayBundle\MBSecureDisplayBundle()

        return $bundles;

Step 3: Config

Define the configuration of the bundle into the config file

# app/config/config.yml
    # Required, key used to encrypt data
    key: "my_super_random_secure_key"
    # Optional, you can customize used template here
    template: 'MBSecureDisplayBundle::secure_display.html.twig'

Step 4: Routing

Register the routing of the bundle to be able to perform ajax requests

# app/config/routing.yml
    resource: "@MBSecureDisplayBundle/Resources/config/routing.yml"
    prefix:   /

Step 5: Assets

Publish the assets to be able to use the javascript file

$ php app/console assets:install --symlink web

Add this line in your layout:

<script src="{{ asset('bundles/mbsecuredisplay/js/display.js') }}"></script>


{{ some.data|secureDisplay(label, action, attributes) }}


  • label: optional
    • type: string
    • value: text to display if the javascript is not enabled
  • action: optional
    • type: string
    • value: action to append before the link (like "tel:012 345 67" or "mailto:john@doe.com")
  • attributes: optional
    • type: array
    • value: html attributes to add to the text


<h4>Here are my personal informations</h4>

{# Default usage #}
<p>My name is : {{ contact.name|secureDisplay }}</p>

{# Custom label when JavaScript is not enabled #}
<p>You can find me at : {{ contact.address|secureDisplay('this address is protected') }}</p>

{# Transform phone number into clicable link #}
{# Can be 'tel', 'mailto', whatever you want #}
<p>My phone number is : {{ contact.phoneNumber|secureDisplay(null, 'tel') }}</p>

{# Custom html attributes #}
<p>My favorite color is : {{ contact.color|secureDisplay(null, null, { 'style': 'color: red' }) }}</p>

Of course, you can mix any of these tree parameters as you want.