Developed with love by KnpLabs Hire us for your project!
30

pomm-bundle

by pomm-project

Symfony2 bundle for Pomm2

Pomm2 bundle for Symfony.

Although this bundle usable already, it is a work in progress. New features will be added.

This bundle provides a pomm service to use the Pomm2 Model Manager with Symfony.

Installation

Simply require pomm-project/pomm-bundle: 2.0.*@dev in your composer.json file and run the update command.

Setup

Add the bundle in the app/AppKernel.php file:

<?php // app/AppKernel.php
// …
    public function registerBundles()
    {
        $bundles = [
        // other bundles
        new \PommProject\PommBundle\PommBundle(),
        // other bundles
        ];

Configuration

In the app/config folder, store your db connection parameters in parameters.yml:

parameters:
    db_host1: 127.0.0.1
    db_port1: 5432
    db_name1: my_db_name
    db_user1: user
    db_password1: pass

    db_host2: 127.0.0.1
#   etc.

Sensitive information such as database credentials should not be committed in Git. To help you prevent committing those files and folders by accident, the Symfony Standard Distribution comes with a file called .gitignore which list resources that Git should ignore, included this parameters.yml file.
You can now refer to these parameters elsewhere by surrounding them with percent (%).

Add an entry in config.yml:

pomm:
    configuration:
        my_db1:
            dsn: 'pgsql://%db_user1%:%db_password1%@%db_host1%:%db_port1%/%db_name1%'
            pomm:default: true
        my_db2:
            dsn: 'pgsql://%db_user2%:%db_password2%@%db_host2%:%db_port2%/%db_name2%'
            class:session_builder: '\PommProject\ModelManager\SessionBuilder'
    logger:
        service: '@logger'

And in routing_dev.yml:

_pomm:
    resource: "@PommBundle/Resources/config/routing.yml"
    prefix:   /_pomm

Command line interface

The Pomm CLI is available through the app/console utility. It is possible to browse the database or to generate model files.

$ ./app/console pomm:generate:relation-all -d src -a 'AppBundle\Model' my_db1 student

Using Pomm from the controller

The Pomm service is available in the DIC as any other service:

    function myAction($name)
    {
        $students = $this->get('pomm')['my_db2']
            ->getModel('\AppBundle\Model\MyDb1\PublicSchema\StudentModel')
            ->findWhere('name = $*', [$name])
            ;

        …

It is now possible to tune and create a model layer as described in the quick start guide.

Param converter

This bundle provide a param
converter

to convert request to a flexible entity. The converter search in the request the
parameters with names matching primary key.

You can specify witch connexion use in the option:


/**
 * @ParamConverter("student", options={"connection": "my_db2"})
 */
public function getAction(Student $student)

By default, the model used for find the entity is deduce by adding Model to
entity class name. If you have a different class name, you can use the model
option:


/**
 * @ParamConverter("student", options={"model": "StudentModel"})
 */
public function getAction(Student $student)

This feature require
sensio/framework-extra-bundle.

  • Merge branch 'stood-master'
    By sanpii, 2 years ago
  • add option pomm:default
    By , 2 years ago
  • Suggest sensio/distribution-bundle
    By sanpii, 2 years ago
  • Merge branch 'stood-master'
    By sanpii, 2 years ago
  • Add name of variable
    By stood, 2 years ago
  • EntityParamConverter support all flexible entities
    By sanpii, 2 years ago
  • Fixed wrong model class name
    By sanpii, 2 years ago
  • Merge pull request #25 from sanpii/param-converter
    By chanmix51, 2 years ago
  • Add entity param converter
    By sanpii, 2 years ago
  • Override data.collector.time service only if defined
    By sanpii, 2 years ago
  • Merge branch 'stood-color_timeline'
    By sanpii, 2 years ago
  • override time template
    By sanpii, 2 years ago
  • Typo in site url in README.
    By chanmix51, 3 years ago
  • Merge branch 'ronanguilloux-ronan'
    By sanpii, 3 years ago
  • README-ing about sensitive db credentials
    By ronanguilloux, 3 years ago
  • services/pomm.yml -> services.yml
    By sanpii, 3 years ago
  • Integrate pomm:inspect:config command
    By sanpii, 3 years ago
  • Enable time profiling
    By sanpii, 3 years ago
  • Automaticaly load @pomm.controller.profiler
    By sanpii, 3 years ago
  • Merge pull request #15 from stood/master
    By chanmix51, 3 years ago
  • reference builder to configuration example
    By stood, 3 years ago
  • Update pomm datacollector id
    By sanpii, 3 years ago
  • Updated README
    By sanpii, 3 years ago
  • Provide pomm service to commands
    By sanpii, 3 years ago
  • Updated README with cli bootstrap.
    By chanmix51, 3 years ago
  • Allow disable profiler
    By sanpii, 3 years ago
  • Configurable routes prefix
    By sanpii, 3 years ago
  • Update README.md
    By sanpii, 3 years ago
  • Merge branch 'explain'
    By sanpii, 3 years ago
  • Integrate EXPLAIN controller
    By sanpii, 3 years ago