Version

Documentation » Classification

3. Classification Types »

« 1. Introduction

2. Installation

  • Add SonataClassificationBundle to your vendor/bundles directory with the deps file:
// composer.json

"require": {
//...
    "sonata-project/classification-bundle": "dev-master",
//...
}
  • Add SonataClassificationBundle to your application kernel:
// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Sonata\ClassificationBundle\SonataClassificationBundle(),
        // ...
    );
}
  • Create a configuration file named sonata_classification.yml:
# sonata_classification.yml

sonata_classification:
    # ...

doctrine:
    orm:
        entity_managers:
            default:
                #metadata_cache_driver: apc
                #query_cache_driver: apc
                #result_cache_driver: apc
                mappings:
                    #ApplicationSonataClassificationBundle: ~
                    SonataClassificationBundle: ~
  • Import the sonata_classification.yml file and enable json type for doctrine:
imports:
    #...
    - { resource: sonata_classification.yml }

# ...
doctrine:
    dbal:
        # ...
        types:
            json:     Sonata\Doctrine\Types\JsonType
  • Run the easy-extends command:
php app/console sonata:easy-extends:generate --dest=src SonataClassificationBundle
  • If necessary add the new namespace to the autoload:
// app/autoload.php

$loader->add("Application", __DIR__.'/src/Application');
  • Enable the new bundle:
// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Application\Sonata\ClassificationBundle\ApplicationSonataClassificationBundle(),
        // ...
    );
}
# sonata_classification.yml

sonata_classification:
    # ...

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    ApplicationSonataClassificationBundle: ~
                    # ...

Found a typo? Something is wrong in this documentation? Just fork and edit it!