2017 © Pedro Peláez
 

symfony-bundle pomm-bundle

The Symfony2 bundle for Pomm2

image

pomm-project/pomm-bundle

The Symfony2 bundle for Pomm2

  • Wednesday, June 20, 2018
  • by chanmix51
  • Repository
  • 13 Watchers
  • 69 Stars
  • 23,596 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 20 Forks
  • 5 Open issues
  • 17 Versions
  • 21 % Grown

The README.md

Pomm2 bundle for Symfony

Build Status Scrutinizer Code Quality, (*1)

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

This bundle provides a pomm service to use the Pomm2 Model Manager with Symfony., (*3)

Note:, (*4)

If you are looking for a bundle for Pomm 1.x then look up for pomm/pomm-bundle on packagist., (*5)

Installation

composer require pomm-project/pomm-bundle

Note:, (*6)

Pomm bundle support symfony flex, the recipe add route for the profiler pannel and a minimal configuration with a db session loaded from DATABASE_URL environment variable., (*7)

Setup

Add the bundle in the app/AppKernel.php file:, (*8)

<?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:, (*9)

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 (%)., (*10)

Add an entry in config.yml:, (*11)

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%"
            session_builder: "pomm.session_builder"
    logger:
        service: "@logger"

And in routing_dev.yml:, (*12)

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

Command line interface

The Pomm CLI is available through the bin/console utility. It is possible to browse the database or to generate model files., (*13)

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

If you want generate schema, you need to use the model manager session builder:, (*14)

pomm:
    configuration:
        my_db1:
            dsn: "pgsql://%db_user1%:%db_password1%@%db_host1%:%db_port1%/%db_name1%"
            session_builder: "pomm.model_manager.session_builder"

Using Pomm from the controller

The Pomm service is available in the DIC as any other service:, (*15)

    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., (*16)

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., (*17)

You can specify witch connexion use in the option:, (*18)


/** * @ParamConverter("student", options={"session": "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:, (*19)


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

This feature require sensio/framework-extra-bundle., (*20)

Serializer

You can use the serializer component to serialize entities., (*21)

Property info

This bundle also provide property info support to retrieve flexible entity properties informations., (*22)

Poolers as service

If you need to add additional poolers into the session builder all you need to do is tag a service definition with pomm.pooler, (*23)

Model and Model layer as a service

Model and model layer objects can be registered as a service. For this to work properly you have to tag your service correctly and remove class:session_builder from configuration., (*24)

Models must be tagged with pomm.model and layers with pomm.model_layer, (*25)

Both of those tags have the following parameters: * pooler which is the name of a default pooler service, if left blank the default is used * session which is the name of a default session service this is used from, if left blank the default is used, (*26)

The Versions

06/12 2017

dev-revert-85-patch-2

dev-revert-85-patch-2 http://www.pomm-project.org

The Symfony2 bundle for Pomm2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nicolas JOSEPH

orm database postgresql symfony pomm

13/04 2017

dev-mvrhov-modelAsService

dev-mvrhov-modelAsService http://www.pomm-project.org

The Symfony2 bundle for Pomm2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nicolas JOSEPH

orm database postgresql symfony pomm

22/12 2016
30/11 2016
24/11 2016
03/01 2016
09/10 2015

2.0.0

2.0.0.0 http://www.pomm-project.org

The Symfony2 bundle for Pomm2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nicolas JOSEPH

orm database postgresql symfony pomm