kzykhys / doctrine-orm-service-provider
Provides Doctrine ORM to Silex application
dev-master
2013-05-29 03:56 UTC
Requires
- doctrine/orm: >=2.2.0,<2.4.0-dev
- silex/silex: 1.0.*@dev
Requires (Dev)
- kzykhys/console-service-provider: dev-master
Suggests
- kzykhys/console-service-provider: Allows doctrine commands on silex application
This package is not auto-updated.
Last update: 2024-12-16 16:11:11 UTC
README
The DoctrineORMServiceProvider provides integration with the Doctrine ORM
Installation
{ "require": { "kzykhys/doctrine-orm-service-provider":"dev-master" } }
Parameters
- orm.cache.dir: The cache directory to store the doctrine cache data.
- orm.entity.path: Array of directory.
- orm.proxy.dir: The directory to store proxy classes.
- orm.proxy.namespace: The namespace of each proxy classes.
Services
- orm.em: Entity Manager for Doctrine, instance of
Doctrine\ORM\EntityManager
. - orm.schema_tool: instance of
Doctrine\ORM\Tools\SchemaTool
.
Usage
<?php use Silex\Application; use Silex\Provider\DoctrineServiceProvider; use KzykHys\Silex\Provider\DoctrineORM\DoctrineORMServiceProvider; $app = new Silex\Application(); $app->register(new DoctrineServiceProvider(), array( 'db.options' => '...' )); $app->register(new DoctrineORMServiceProvider(), array( 'orm.cache.dir' => __DIR__ . '/app/cache/doctrine/orm', 'orm.entity.path' => array(__DIR__ . '/path/to/entity_dir'), 'orm.proxy.dir' => __DIR__ . '/app/cache/doctrine/proxies', 'orm.proxy.namespace' => 'Your\Namespace\Orm\Proxies' )); $app->get('/new', function (Application $app) { $user = new User(); $app['orm.em']->persist($user); $app['orm.em']->flush(); });