tamago/tips-manager-bundle

Simple bundle to show tips

dev-master 2016-05-04 22:13 UTC

This package is not auto-updated.

Last update: 2024-12-21 19:21:21 UTC


README

Build Status SensioLabsInsight

This Symfony bundle allows to integrate a Tip Manager in your Symfony application. The Tip Manager shows you tips relevant to your application. The tips can be seen in different languages.

The idea is to:

  • write tips and their translations in files (yml) for at least one language (the default language of your website for example).
  • load tips and their translations into the database by using command line.
  • freely edit/add translation through an edition page.

You can also provide feedback for a tip through like/dislike buttons. The feedback and other details related to the tips can be viewed on a stats page.

Here is a screenshot of what an example tip looks like:

tip screenshot

Installation

Add the bundle to your composer.json file:

require: {
    // ...
    "tamago/tips-manager-bundle": "dev-master"
}

Or install directly through composer with:

# Latest stable
composer require tamago/tips-manager-bundle dev-master

Then run a composer update:

composer update
# OR
composer update tamago/tips-manager-bundle # to only update the bundle

TamagoTipManagerBundle also installs LexikTranslationManagerBundle which it uses as the mechanism for storing and editing translated tips. Make sure both bundles are registered with your kernel:

// in AppKernel::registerBundles()

$bundles = array(
    // ...
    new Tamago\TipsManagerBundle\TamagoTipsManagerBundle(),
    new Lexik\Bundle\TranslationBundle\LexikTranslationBundle(), //if you don't have this installed already
    // ...
);

Integration

⚠️ Although LexikTranslationManagerBundle supports Doctrine storage types, TamagoTipManagerBundle currently only formally supports Doctrine ORM.

Creating the database schema

php app/console doctrine:database:create
php app/console doctrine:schema:update

Render in the pages where you want the tips to show up

{{ render(controller('TamagoTipsManagerBundle:TipsManager:index', {'domain': 'some-domain-name', 'identifier': 'my-identifier'})) }}

The values of 'domain' and 'identifier' attributes in above should respectively be the custom names of the domain and identifier which the tips belong to. You can split tips into multiple categories/domains.

Configuration

Minimum Configuration

You can skip this step if you are already using LexikTranslationBundle.

You must at least define a fallback locale(s).

lexik_translation:
    fallback_locale: [<locale>] 
    managed_locales: [ <locale1>, <local2>, ... ]
    storage:
        type: orm
        object_manager: <entity/object manager name>

Import translations

To import translations files content into your database, place tip translation YAML files somewhere in your project and import from the directory. For example:

php app/console lexik:translations:import -p app/Resources/translations/tips/

See tips-example.en.yml for an example of a simple translation file.

Routing

To use the tamago based admin pages, add this to routing file of your application:

# app/config/routing.yml
tip_bundle_homepage:
    resource: "@TamagoTipsManagerBundle/Resources/config/routing.yml"
    prefix:   /_tips

The stats page will be available here:

  • /_tips/stats

A screenshot of the stats page: stats page screen

The page to edit/add tips will be available here:

  • /_tips/editor

A screenshot of the edition page: edition page screen