palma / doctrineormserviceprovider
A Silex DoctrineORM Service provider
Installs: 2 665
Dependents: 2
Suggesters: 1
Security: 0
Stars: 11
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: >=5.3.3
- doctrine/orm: >=2.2, ~2.5
Requires (Dev)
- phpunit/phpunit: ~4.4.5
- silex/silex: 1.*
This package is not auto-updated.
Last update: 2024-12-13 15:30:44 UTC
README
This library provides you a Silex DoctrineORM Service provider.
This service provider requires PHP 5.3+, Silex and DoctrineORM.
DoctrineORM is included in composer.json.
Parameters
- doctrine_orm.entities_path: The path to entities.
- doctrine_orm.proxies_path: The path to proxies.
- doctrine_orm.proxies_namespace: The proxies namespace.
- doctrine_orm.connection_parameters: Array of Doctrine DBAL connection params. The DBAL configuration is explained in DBAL configuration
- doctrine_orm.metadata_cache: Optional. This param sets the cache implementation to use for caching metadata information. The default value is Doctrine\Common\Cache\ArrayCache. Don't use it for production.
- doctrine_orm.query_cache: Optional. This param sets the cache implementation to use for caching DQL queries. The default value is Doctrine\Common\Cache\ArrayCache. Don't use it for production.
- doctrine_orm.result_cache: Optional. This param sets the cache implementation to use for caching query results information.
- doctrine_orm.autogenerate_proxy_classes: Sets whether proxy classes should be generated automatically at runtime by Doctrine. If set to FALSE, proxy classes must be generated manually through the doctrine command line task generate-proxies. The strongly recommended value for a production environment is FALSE. The default value is TRUE.
- doctrine_orm.simple_annotation_reader: Optional. This annotation reader is intended to be used in projects where you have full-control over all annotations that are available.
Registering
<?php ... $app->register(new Palma\Silex\Provider\DoctrineORMServiceProvider(), array( 'doctrine_orm.entities_path' => __DIR__.'/Entities/', 'doctrine_orm.proxies_path' => __DIR__.'/Proxies', 'doctrine_orm.proxies_namespace' => 'MyProject\Proxies', 'doctrine_orm.connection_parameters' => array( 'driver' => 'pdo_mysql', 'dbname' => 'dbname', 'user' => 'usename', 'password' => '******', 'host' => 'localhost', 'charset' => 'utf8', ) ));
Usage
<?php $app->get('/blog/show/{id}', function ($id) use ($app) { $post = $['doctrine_orm.em']->find('Post', $id); return "<h1>{$post->getTitle()}</h1>". "<p>{$post->getBody()}</p>"; });