px/backend

pxBackendBundle lets you create administration backends for Symfony applications with unprecedented simplicity.

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Language:JavaScript

dev-master 2016-05-16 09:04 UTC

This package is not auto-updated.

Last update: 2024-04-19 20:15:55 UTC


README

❮ NOTE ❯ This bundle require EasyAdminBundle. Start with reading the the documentation of [EasyAdmin] (https://github.com/javiereguiluz/EasyAdminBundle) to learn how to create complex backends.

Installation pxBackendBundle

Step 1: Download the Bundle

In your composer.json add the following code:

"px/backend": "dev-master"

Then

$ composer update

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

Step 2: Enable the Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new JavierEguiluz\Bundle\EasyAdminBundle\EasyAdminBundle(),
            new px\BackendBundle\pxBackendBundle(),
        );
    }

    // ...
}

Step 3: Load the Routes of the Bundle

# app/config/routing.yml
px_backend:
    resource: "@pxBackendBundle/Controller/"
    type:     annotation
    prefix:   /admin

easy_admin_bundle:
    resource: "@EasyAdminBundle/Controller/"
    type:     annotation
    prefix:   /admin


# ...

Step 4: Prepare the Web Assets of the Bundle

# Symfony 2
php app/console assets:install 

# Symfony 3
php bin/console assets:install

That's it! Now everything is ready to create your first admin backend.

Your First Backend

Creating your first backend will take you less than 30 seconds. Let's suppose that your Symfony application defines one Doctrine ORM entity called Ticket.

Open the app/config/config.yml file and add the following configuration:

# app/config/config.yml
imports:
    - { resource: @pxBackendBundle/Resources/config/config.yml }

Open the px/BackendBundle/Resources/config/config.yml file and add the following configuration:

# px/BackendBundle/Resources/config/config.yml
imports:
    - { resource: admin.yml }
easy_admin:
    entities:
        Ticket:
            templates:
                flash_messages: "pxBackendBundle:Default:flash_messages.html.twig"
                layout: "pxBackendBundle:Default:layout.html.twig"
            class: AppBundle\Entity\Ticket

Open the px/BackendBundle/Resources/config/admin.yml file and add the following configuration:

# px/BackendBundle/Resources/config/admin.yml
parameters:
    Ticket:
        entity_path: AppBundle\Entity\Ticket
        entity_name: AppBundle:Ticket
        table_id: dt_admin_table
        main_alias: d
        fields:
            0:
                name: id
                label: Id
                tabSortable: true
                tabVisible: true
                tabSearchable: true
                sClass: " center col-sm-2 col-md-2"

            1:
                name: actions
                label: Actions
                tabSortable: false
                tabVisible: true
                tabSearchable: false
                sClass: "col-sm-2 col-md-2 table-action center"
        default_order: 
            name: id
            index: 0
            sens: asc

Open the Repository/TicketRepository file and add the following code:

<?php
//...
use px\BackendBundle\Repository\AdminRepository as AdminRepository;

/**
 * TicketRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class TicketRepository  extends AdminRepository {

}

Congratulations! You've just created your first fully-featured backend! Browse the /admin URL in your Symfony application and you'll get access to the admin backend

Keep reading the rest of the documentation of [EasyAdmin] (https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/getting-started.md) to learn how to create complex backends.

License

This software is published under the MIT License