Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Doctrine ORM service provider extension for Silex
PHP

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
nbproject
src/Mparaiso
tests
.gitignore
.travis.yml
LICENSE
README.md
SYMFONY LICENSE
composer.json
console.php
phpunit.xml

README.md

Doctrine ORM Service Provider

Build Status

Doctrine ORM silex extension

author : M.Paraiso contact: mparaiso@online.fr

status: work in progress

helps use Doctrine ORM with silex

Configuration

here is a configuration exemple for silex:

$app->register(new ConsoleServiceProvider); // to manage entities through command line.
$app->register(new DoctrineServiceProvider,array(
        "db.options"=> array(
            "dbname"   =>  getenv("DBNAME"),
            "user"     => getenv("USER"),
            "password" => getenv("PASSWORD"),
            "host"     => getenv("_HOST"),
            "driver"   => "pdo_mysql",
)));

$app->register(new DoctrineORMServiceProvider, array(
       "orm.driver.configs"    => array(
           "default" => array(
               "namespace"=>"Entity",  // rootnamespace of your entities
               "type"  => "yaml", // driver type (yaml,xml,annotation)
               "paths" => array(__DIR__ . '/doctrine'), // config file path
           )
       )
   ));

Services :

  • orm.em : EntityManager
  • orm.manager_registry : Manager registry

FEATURES

FixtureLoader

load fixtures from a yaml file

Usage

given the following yaml file :

/*

## fixture example :

# !!!! all references must be declared BEFORE used !!!!!

# the root node
fixtures: 
  # a fixture      
  - entity: Entity\Rdv\Rsvp 
    # the class
    name: jacob
    # the fixture reference name (optional)
    fields:
      # the fixture properties
      attendeeName: jacob


  - entity: Entity\Rdv\Dinner
    name: 'German dinner'
    fields:
      country: Germany
      latitude: 10
      longitude: 23
      contactPhone: 911-343-333
      address: Berlin
      description: Sausages
      title: Kraut party
      hostedBy: Von Brohm
      eventDate: { datetime: 2013-10-20 }
      # will be parsed as a DateTime object
      rsvps: [ jacob ]
      # will be parsed as an ArrayCollection , fixtures are references by their names
      # references must be declared BEFORE they are USED !!!!

  - entity: Entity\Rdv\Rsvp
    name: jean
    fields:
      attendeeName: jean
      dinner: %German dinner% 
      # a reference to another fixture  , with its name surrounded by quotes
        $em = app['orm.em'] // given a EntityManager
        $loader = new Mparaiso\Doctrine\ORM\FixtureLoader(__DIR__ . '/fixtures/dinners.yml');
        // get entities from fixtures
        $entities = $loader->parse();
        // persist fixtures
        $loader->persistFixtures($em);
        // remove fixtures
        $loader->removeFixtures($em);
Something went wrong with that request. Please try again.