2017 © Pedro Peláez
 

symfony-bundle metronic-crud-generator-bundle

Sensio generator extended to implements Metronic Bundle on Crud Generator.

image

ruudy/metronic-crud-generator-bundle

Sensio generator extended to implements Metronic Bundle on Crud Generator.

  • Thursday, April 2, 2015
  • by ruudy
  • Repository
  • 0 Watchers
  • 2 Stars
  • 2,063 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

METRONIC CRUD GENERATOR BUNDLE

SensioLabsInsight Total Downloads Latest Stable Version License, (*1)

This bundle extends the symfony2 crud generator and, (*2)

I apologize for the inconvenience that my english can produce., (*3)

Thanks to Sonata Project, their code inspire me on how to do some things., (*4)

Thanks to Metronic - Responsive Admin Dashboard Template creators for the good treatment received., (*5)

License

This bundle is under the MIT license. See the complete license in the bundle:, (*6)

Resources/meta/LICENSE

Instalation

Installation is a quick 4 step process:, (*7)

  1. Configure Metronic Bundle (if Needed)
  2. Download over composer
  3. Enable the bundle
  4. Generate the required files for the bundle
  5. Extending & Configurating it (optional)

Step 1. Configure Metronic Bundle (if Needed)

This package have dependencie of Ruudy - MetronicBundle, (*8)

If you didn't follow the Metronic Bundle installation steps you must stop reading this readme and first of all, install and configure that bundle., (*9)

Ruudy - MetronicBundle Readme, (*10)

Step 2. Download over composer

Add RuudyMetronicCrudGeneratorBundle require line to your composer.json:, (*11)

"require": {
    "ruudy/metronic-crud-generator-bundle": "@dev"
}

$ php composer.phar install

or just add it by running the command:, (*12)

$ php composer.phar require ruudy/metronic-crud-generator-bundle '@dev'

Composer will install the bundle to your project's ruudy/metronic-crud-generator-bundle directory., (*13)

Step 3. Enable the bundle

Enable the bundle in the kernel:, (*14)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Ruudy\MetronicCrudGeneratorBundle\RuudyMetronicCrudGeneratorBundle(),
    );
}

Step 4. Generate the required files for the bundle

At this point, the bundle is not yet ready and you must choose between use default basic views provided in this bundle, or create your own. I recommend test this bundle with default view, but if you want create your layouts from scratch, you can go directly to Step 5., (*15)

You need to generate the correct files and folders for the twig inherance:, (*16)

$ php app/console ruudy:metronic-crud-generator:generate

This command will generate and skeleton bundle on src/Application/Ruudy/, and some folders to populate with the Metronic Template Assets., (*17)

After this, add new bundle to kernel:, (*18)

<?php
    // app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Application\Ruudy\MetronicBackEndBundle\ApplicationMetronicBackEndBundle(),
        );
    }

Step 5. Extending & Configurating it (optional)

If you are familiar with the Doctrine Crud Generator you know that the skeleton for the crud can be stored on many paths in you application, if not, i recommend you read the official documentation:, (*19)

[Symfony2 - Overriding Skeleton Templates][3], (*20)

By default, this bundle comes with 3 paths to recognize the skeleton needed for generating the crud files., (*21)

$skeletonDirs[] = $this->getContainer()->get('kernel')->locateResource('@RuudyMetronicCrudGeneratorBundle/Resources/skeleton');
$skeletonDirs[] = $this->getContainer()->get('kernel')->locateResource('@RuudyMetronicCrudGeneratorBundle/Resources');
$skeletonDirs[] = $this->getContainer()->get('kernel')->locateResource('@RuudyMetronicBundle/Resources');

The order you add the locations is important becuase it define the preference when Generator search required files, so this bundle allow you to override or add locations:, (*22)

    // app/config/config.yml

    // ...
    ruudy_metronic_crud_generator:
        override_resource_locations: []
        add_resource_locations_ []

Locations defined on override will be included before default bundle Dirs, locations you add, after., (*23)

This functionality allow you to modify the basic layout i propose or just create new one., (*24)

Usage

After installation you can just use the bundle generated in:, (*25)

src/Application/Ruudy
  1. Extend the bundle with your own Company/StoreBundle (take care of the views you need)
  2. Use the bundle generated in src/Application/Ruudy

Entity class is needed in the process, so create one if you dont have it:, (*26)

$ php app/console generate:doctrine:entity

Or just run and follow the steps:, (*27)

$ php app/console ruudy:metronic-crud-generator:crud

Command will create necessary Controllers, form types, views and tests., (*28)

Common Errors $ Doubts

-- Dont forget to add the annotation route in one of your routng files, in this example i use yml, so in one of my "routing.yml" loaded., (*29)

cruds:
  resource: "@CompanyStoreBundle/Controller/"
  type: annotation
  prefix: /admin

-- I suppose you will use this bundle in an private admin enviroment, for avoid errors i added this check:, (*30)

// src/Application/Ruudy/MetronicBackEndBundle/Resources/views/zones/admin/header.html.twig

{% if app.user.username is defined %}
    {{ app.user.username }}
{% endif %}

-- Like previous point, logout path is normally in all backoffice applications:, (*31)

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "logout" as such route does not exist.")

Can be easy bypass adding:, (*32)

logout:
    path: /logout

-- Dont forget to follow Metronic Bundle installation steps or you will see non styled pages., (*33)

The Versions

02/04 2015

dev-master

9999999-dev

Sensio generator extended to implements Metronic Bundle on Crud Generator.

  Sources   Download

MIT

The Requires

 

by Daniel Abad Cambronero

symfony2 crud cms metronic backoffice admin template metronic bundle metronic crud generator metronic crud generator bundle crud template