sbs/symfony-adminlte-bundle

Symfony2 Project AdminLTE Integration Bundle

Installs: 13 383

Dependents: 0

Suggesters: 0

Stars: 8

Watchers: 2

Forks: 5

Open Issues: 3

Type:symfony-bundle

1.1.4 2018-10-15 14:05 UTC

README

AdminLTE Bundle based on the AdminLTE Template for easy integration into Symfony. This bundle integrates several commonly used JavaScripts and Font-Awesome.

From version 1.1.x bundle use AdminLTE 2.4.x all theme changes you can find in official AdminLTE blog.

Installation

Installation using composer is really easy: Configure components installers directory in composer.json:

"extra": {
    "installer-types": ["library", "component"],
    "installer-paths": {
        "web/components/{$name}/": ["type:component"]
    },
},

After that run the next composer command to download and add bundle sbs/symfony-adminlte-bundle to your composer.json:

composer require sbs/symfony-adminlte-bundle

Configurations

Enable the bundle in your kernel:

<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new SbS\AdminLTEBundle\SbSAdminLTEBundle(),
        new AppBundle\AppBundle(),
    );
}

Configure composer.json to install AdminLTE assets into bundle public directory.

Notice: insert line before Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets

"scripts": {
    "symfony-scripts": [
        "SbS\\AdminLTEBundle\\Composer\\ScriptHandler::buildAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
    ],
    "post-install-cmd": [
        "@symfony-scripts"
    ],
    "post-update-cmd": [
        "@symfony-scripts"
    ]
},

Add the following lines at app/config/routing.yml:

sbs_adminlte:
    resource: "@SbSAdminLTEBundle/Resources/config/routing.xml"

Notice for Symfony 2.8 and higher

Notice: This bundle requires assetic, but it isn't shipped with Symfony anymore since version 2.8.

Assetic will be installed as require bundle and you should enable bundle in your kernel:

<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new SbS\AdminLTEBundle\SbSAdminLTEBundle(),
    );
}

Add the following lines at app/config/config.yml:

# Assetic Configuration
assetic:
    debug: "%kernel.debug%"
    use_controller: "%kernel.debug%"
    filters:
        cssrewrite: ~

And following lines at app/config/config_dev.yml:

# Assetic Configuration
assetic:
    use_controller: false

For Symfony 3.4 and higher next snippet should be added to framework section.

framework:
    # ...
    templating:
        engines: ['twig']

Install Assets and Dump Assetic (run the following two commands):

For Symfony 2.8.*

php ./app/console assets:install
php ./app/console assetic:dump

For Symfony 3.4.*

php ./bin/console assets:install
php ./bin/console assetic:dump

Changing default values template

If you want to change any default value as for example skin all you need to do is define the same at app/config/config.yml under [twig] section. See example below:

# Twig Configuration
twig:
    # ...
    globals:
        admin_lte_skin: skin-blue
    # ...

You could also define those values at app/config/parameters.yml:

app.skin: skin-blue

and then use as follow in app/config/config.yml:

# Twig Configuration
twig:
    # ...
    globals:
        admin_lte_skin: "%app.skin%"

AdminLTE skins are: skin-blue (default for this bundle), skin-blue-light, skin-yellow, skin-yellow-light, skin-green, skin-green-light, skin-purple, skin-purple-light, skin-red, skin-red-light, skin-black and skin-black-light. If you want to know more about theme then go ahead and check docs for AdminLTE.

There are a few values you could change for sure without need to touch anything at bundle, just take a look under Resources/views.

Next Steps

That's all. Enjoy.