2017 © Pedro PelĂĄez
 

symfony-bundle knit-bundle

Knit integration with Symfony3.

image

michaldudek/knit-bundle

Knit integration with Symfony3.

  • Monday, January 11, 2016
  • by michaldudek
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Knit Bundle

Knit ties your PHP objects with your database of choice in a simple way. Read more about Knit in its repository., (*1)

This is a Symfony3 Bundle that integrates Knit with the framework., (*2)

Build Status SensioLabsInsight, (*3)

Installation

Require the bundle:, (*4)

$ composer require michaldudek/knit-bundle

Enable the bundle in your Kernel:, (*5)

<?php

// ...

    public function registerBundles()
    {
        $bundles = [
            // ...

            new Knit\Bundle\KnitBundle(),
        ];
        // ...
    }

Configuration

Add knit section to your config.yml., (*6)

There are three available settings and all of them are just names of services you want injected to the main Knit\Knit class (those will serve as defaults for all repositories)., (*7)

knit:
    # required, default store
    store: [store.service_name]

    # optional, default data mapper, "knit.data_mapper.array_serializer" by default
    data_mapper: [data_mapper.service_name]

    # optional, event dispatcher used, "event_dispatcher" by default
    event_dispatcher: [event_dispatcher.service_name]

Configuring a Store

As you can see, for Knit, a store is nothing more than a dependency that needs to be injected. This gives you power to configure your stores in any way you want., (*8)

For convenience, KnitBundle registers two dependencies for the two stores it implements so far: knit.store.doctrine_dbal.criteria_parser and knit.store.mongodb.criteria_parser. It also registers two parameters for easier resolution of store classes: %knit.store.doctrine_dbal.class% and %knit.store.mongodb.class%., (*9)

Using these two aspects you can easily configure your data stores and register them in the container:, (*10)

services:

    mysql_store:
        class: %knit.store.doctrine_dbal.class%
        arguments:
            - driver: pdo_mysql
              user: %db.username%
              password: %db.password%
              host: %db.host%
              dbname: %db.database%
            - @knit.store.doctrine_dbal.criteria_parser
            - @logger

    # or

    mongodb_store:
        class: %knit.store.mongodb.class%
        arguments:
            - hostname: %mongo.host%
              database: %mongo.database%
              username: %mongo.username%
              password: %mongo.password
            - @knit.store.mongodb.criteria_parser
            - @logger

where all the connection parameters you have to register yourself, obviously., (*11)

Then in config.yml you can just specify:, (*12)

knit:
    store: mysql_store    # or mongodb_store

Repositories

By convention, all repositories should be registered as services. You are going to inject them into other services or controllers anyway, so for clarity KnitBundle doesn't automagically creates them., (*13)

An example definition of a repository is like this:, (*14)

user.repository:
    parent: knit.repository
    arguments: [MyApp\User, "users"]

where 1st argument is the managed object class name and second a collection name. Additional arguments are also allowed - see Knit documentation for details on what they are., (*15)

License

MIT, see LICENSE.md., (*16)

Copyright (c) 2015 MichaƂ PaƂys-Dudek, (*17)

The Versions

11/01 2016

dev-master

9999999-dev

Knit integration with Symfony3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by MichaƂ PaƂys-Dudek

orm database postgresql mysql mongo odm datamapper pgsql popo

11/01 2016

0.3.0

0.3.0.0

Knit integration with Symfony3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by MichaƂ PaƂys-Dudek

orm database postgresql mysql mongo odm datamapper pgsql popo

11/01 2016

dev-release/0.2

dev-release/0.2

Knit integration with Symfony2.

  Sources   Download

MIT

The Requires

 

The Development Requires

by MichaƂ PaƂys-Dudek

orm database postgresql mysql mongo odm datamapper pgsql popo

13/10 2015

0.2.0

0.2.0.0

Knit integration with Symfony2.

  Sources   Download

MIT

The Requires

 

The Development Requires

by MichaƂ PaƂys-Dudek

orm database postgresql mysql mongo odm datamapper pgsql popo