Giter Club home page Giter Club logo

nutwerk-orm-extension's Introduction

Doctrine ORM Service Provider for Silex

This extension sets up Doctrine ORM for Silex by reusing the database connection established with the DBAL extension (the default DoctrineServiceProvider included with Silex).

Note : This provider is not maintained anymore ; you will find a better provider for DoctrineORM, which is maintained and updated by Beau Simensen (@simensen) : dflydev/doctrine-orm-service-provider

Note : This provider was first created and provided by Marc Jakubowski, but due to unknown reason, he can't maintain it anymore, as Silex API evolved since the last modification.

You'll find the following topics in this README:

Dependencies

Installation

You basically have three options to add this extension to your Silex project. We'd strongly recommend the first option!

composer.json

http://packagist.org/packages/taluu/doctrine-orm-provider

Add 'taluu/doctrine-orm-provider' to the dependencies in your projects composer.json file and update your dependencies. This is by far the easiest way, since it automatically adds the Doctrine dependencies and adds everything to the autoloading mechanism supplied by Composer.

More information on Composer can be found on getcomposer.org.

Git

Another option is to clone the project:

cd /path/to/your_project/vendor
git clone git://github.com/taluu/nutwerk-orm-extension.git

Or you can add it as a submodule if your project is in a git repository too:

cd /path/to/your_project
git submodule add git://github.com/taluu/nutwerk-orm-extension.git vendor/nutwerk-orm-extension

This will require you to manually install all the dependencies. Also note that you'll need to add the provider to the autoloading mechanism by hand. More on both subjects can be found below.

Download an archive

GitHub also gives you the option to download an ZIP-archive, which you can extract in your vendor folder. This method will also require you to manually install all the dependencies and add everything to your autoloader.

Configuration

First of all you should have the Doctrine DBAL connection configured. For more information about configuring the DoctrineServiceProvider, I'd recommend reading this page of the Silex documentation.

Registering the Doctrine ORM Service Provider is rather straight forward:

<?php

/* ... */

// If you're not using Composer, you'll need to register the Nutwerk vendor to wherever you downloaded the library

$app->register(new Nutwerk\Provider\DoctrineORMServiceProvider(), array(
    'db.orm.proxies_dir'           => __DIR__.'/var/cache/doctrine/Proxy',
    'db.orm.proxies_namespace'     => 'DoctrineProxy',
    'db.orm.auto_generate_proxies' => true,

    'db.orm.entities'              => array(array(
        'type'      => 'annotation',
        'path'      => __DIR__.'/app',
        'namespace' => 'Entity',
    )),
));

/* ... */

Parameters (and their default values)

Below you'll find all the parameters with their defaults (they can also be found in DoctrineORMServiceProvider::setOrmDefaults).

  • db.orm.auto_generated_proxies

    Default : true

    Sets whether proxy classes should be generated automatically at runtime by Doctrine. If set to false, proxy classes must be generated manually using the Doctrine command line tools. It is recommended to disable autogeneration for a production environment.

  • db.orm.cache

    Default : new ArrayCache

    Defines what caching method should be used. The default (ArrayCache) should be fine when you're developing, but in a production environment you probably want to change this to something like APC or Memcache. More information can be found in Chapter 22. Caching of the Doctrine 2 ORM 2.1 documentation.

  • db.orm.entities

    Default:

array(
    array(
        'type' => 'annotation',
        'path' => 'Entity',
        'namespace' => 'Entity',
    )
)
An array of arrays which should contain:
*   ``type``: Type of metadata driver used (``annotation``, ``yml``, ``xml``)
*   ``path``: Path to where the metadata is stored
*   ``namespace``: Namespace used for the entities

The Doctrine ORM Service Provider uses a _DriverChain_ internally to configure Doctrine 2 ORM.
This allows you to use mixed types of metadata drivers in a single project.
  • db.orm.proxies_dir

    Default: cache/doctrine/Proxy

    Sets the directory where Doctrine generates any proxy classes. For a detailed explanation on proxy classes and how they are used in Doctrine, refer to section 3.5 Proxy Objects of the Doctrine ORM documentation.

  • db.orm.proxies_namespace

    Default: DoctrineProxy

    Sets the namespace to use for generated proxy classes. For a detailed explanation on proxy classes and how they are used in Doctrine, refer to section 3.5 Proxy Objects of the Doctrine ORM documentation.

Usage

You can access the EntityManager by calling $app['db.orm.em'].

nutwerk-orm-extension's People

Contributors

mjakubowski avatar taluu avatar itavero avatar shawjb avatar

Stargazers

samdus avatar Pedro Ribeiro avatar Etienne Dauvergne avatar Martin Caminoa avatar Adrian avatar Stepan Anchugov avatar Pascal Polleunus avatar

Watchers

Domingos Teruel avatar julietaCuadrado avatar James Cloos avatar  avatar

nutwerk-orm-extension's Issues

Update for Silex 1.1

Hi,

Currently this service provider only supports Silex 1.0.*, would it be possible to update for 1.1 or 1.2?

Thanks

releasing a stable version

I'm currently using Silex and I want to use Doctrine ORM.

I've found your package and it provides what I want :)

The problem is I always use « stable » packages and your package is not « stable ».
To make him « stable », you have to make a release (« v1.0.0 » maybe ;) )

So it's possible to create a release ?

Annotations issues in Silex (Class xxx is not a valid entity or mapped super class )

Hello,
First of all, thanks for your work.

I'm using this provider with Silex and JMSSerializerBundle, thus I need to swich from @Entity to @ORM\Entity notation.

I Wonder if there is a way add to your code a way to specify the wished notation to allow it reach your function loadDoctrineConfiguration(Application $app),

maybe adding
'ORMPrefix' => true/falsevalue,
the configutarion array
'entities' => array(
array(
'type' => 'annotation',
'path' => 'Entity',
'namespace' => 'Entity',
'ORMPrefix' => 'false',
)
and the using it in
$driver = $config->newDefaultAnnotationDriver((array)$entity['path'],$entity['ORMPrefix']);

could do the magic.

Sorry for using issues tab, I'm a noob in Github

Thanks again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.