Symfony 3 Admin Panel to create and edit configurations usable in Twig and Controllers of your application
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Controller First commit, v1.0.0 Aug 10, 2018
DependencyInjection First commit, v1.0.0 Aug 10, 2018
Entity First commit, v1.0.0 Aug 10, 2018
Form
Repository First commit, v1.0.0 Aug 10, 2018
Resources First commit, v1.0.0 Aug 10, 2018
Services First commit, v1.0.0 Aug 10, 2018
.gitignore First commit, v1.0.0 Aug 10, 2018
LICENSE First commit, v1.0.0 Aug 10, 2018
NavalexConfigBundle.php
README.md Update README.md Aug 10, 2018
composer.json First commit, v1.0.0 Aug 10, 2018

README.md

NavalexConfigBundle

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available

Allows you to create configurations that can be used in your project (Twig and Controller services) and manage them through an admin panel divided into two parts:

  • Configuration forms divided in category and fieldset to edit values of your configs:
  • Create Category, Fieldset and Configuration field for you forms

Installation

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

$ composer require navalex/config-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require navalex/config-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
            new Navalex\ConfigBundle\NavalexConfigBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Update database

To make the plugin work, you need to update database table by entering the following command:

$ php bin/console doctrine:schema:update --force

Configuration

Step 1: Enable routes

Open app/config/routing.yml and add:

# app/config/routing.yml

navalex.config_bundle:
    resource: '@NavalexConfigBundle/Resources/config/routing.yml'

(Optional) Step 2: Protect admin panel

If you want to restrict access to the panel to a specific role you can something like that (restrict access for ROLE_ADMIN only) in app/config/security.yml:

# app/config/security.yml

security:
    
    # ...

    role_hierarchy:
         # ...
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    access_control:
         # ...
        - { path: ^/admin/, role: ROLE_ADMIN }

Step 3: Update cache

Once evrything is done, update symfony cache to access to the panel

$ php bin/console cache:clear
or
$ php bin/console cache:clear --env=prod

Usage

Step 1: Create configurations

Go to http://<your_website>/admin/config/admin/config/conf

Here you can create Form Category, then give it fieldsets to organize your form, and finaly create configuration. Here a detail of configuration fields:

  • Name: Admin form label for this configuration
  • Code: Unique code to call the configuration in Twig and Controller
  • Category/Field: Select form and fieldset for this configuration
  • Type: What kind of field will be the configuration By default, the bundle give the value "data" to every new configuration.

Step 2: Edit configurations value

You'll now see your configurations category form appear on the navbar of the panel. Just go on it and enjoy !

Step 3: Call the configuration in your project

In Controller:

$configs = $this->get('navalex_config.config');
$configs->get('<your_configuration_code>');

In Twig:

{{ getConfig('<your_configuration_code>') }}

Incoming Features

  • Translation domain for configuration label
  • New complexe field types:
    • Array (with text inputs added with ajax button)
    • Image (with automatique upload and naming)
  • Complete Navapanel Dashboard
  • Order Form Category in the panel
  • Get config from ajax with API url like http://<your_website>/config/<code> and JSON return
  • Customize field types in symfony configuration
  • ...

License

This bundle is under the MIT license. See the complete license in the bundle