How do I dependency inject PDO to a service in Symfony2?

just.another.newbie

I'm working with a library in the vendor/ directory and designating it as a service within Symonfy2. The library has a dependency on a PDO connection -- how do I set up my service definition to pass that to the constructor?

I'm trying something like this:

services:
    timers.mysql.service
        class : Fmp\Timers\Record
        factory_service : doctrine.orm.default_entity_manager
        factory_method : getConnection

Which is giving me errors. Any help appreciated. Note, the library I can't modify - it needs a PDO connection, not a doctrine entity manager

Cerad
services:
timers.mysql.service
    class : Fmp\Timers\Record
    factory_service : database_connection
    factory_method : getWrappedConnection

That should give you an object extended from PDO.

Otherwise, you might just need to define your very own pdo object. The database session handler used to have an example. BTW, factory_service and method are depreciated. Might look at using the factory item.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How do I dynamically inject an Angular2 sub component via typescript code?

来自分类Dev

Inject Dependency Value Into Enum

来自分类Dev

Symfony2 - Console commands, how can I setup environment configuration?

来自分类Dev

How do I gracefully handle this exception in a background thread in a Windows service?

来自分类Dev

Symfony2:将其保留为功能还是创建Service?

来自分类Dev

Symfony2,在数据库中配置pdo会话存储

来自分类Dev

Symfony2主义PDO MySQL与LOAD DATA LOCAL INFILE的连接

来自分类Dev

How do I select list of generic objects in abstract service using CriteriaQuery

来自分类Dev

How do I have an Async function that writes out to a service bus queue?

来自分类Dev

How can I do to use a email service for a same domain on other server

来自分类Dev

How do I prevent Apache service from auto-starting on Linux?

来自分类Dev

How do I Download the Symfony Distribution as Zip archive?

来自分类Dev

symfony2中的MySQL(PDO)错误:驱动程序中发生异常:SQLSTATE [HY000] [1049]

来自分类Dev

symfony2中的MySQL(PDO)错误:驱动程序中发生异常:SQLSTATE [HY000] [1049]

来自分类Dev

使用 Symfony2 和 PDO_odbc 并使用服务和存储库进行连接和查询

来自分类Dev

Symfony2 Adding 3rd party Bundles to a Service Controller

来自分类Dev

Symfony2 phpexcel和service_xls5有问题

来自分类Dev

Using Dependency Injection I find myself creating factories to do Unit Testing. Is this normal?

来自分类常见问题

How do I resolve ClassNotFoundException?

来自分类Dev

How inject $stateProvider in angular application?

来自分类Dev

ORDER BY 2参数PDO

来自分类Dev

How do paths work in a Java deployed REST web service?

来自分类Dev

Inject AngularJS 1.2 $location service into controller not working in PhoneGap 3.0

来自分类Dev

在Spring MVC中使用@ Controller,@ Service和@Inject

来自分类Dev

How can I enable or disable a windows service in .NET?

来自分类Dev

Symfony2 PagerFantaBundle

来自分类Dev

symfony2 createQueryBuilder

来自分类Dev

路由symfony2

来自分类Dev

Symfony2 registerBundles()

Related 相关文章

  1. 1

    How do I dynamically inject an Angular2 sub component via typescript code?

  2. 2

    Inject Dependency Value Into Enum

  3. 3

    Symfony2 - Console commands, how can I setup environment configuration?

  4. 4

    How do I gracefully handle this exception in a background thread in a Windows service?

  5. 5

    Symfony2:将其保留为功能还是创建Service?

  6. 6

    Symfony2,在数据库中配置pdo会话存储

  7. 7

    Symfony2主义PDO MySQL与LOAD DATA LOCAL INFILE的连接

  8. 8

    How do I select list of generic objects in abstract service using CriteriaQuery

  9. 9

    How do I have an Async function that writes out to a service bus queue?

  10. 10

    How can I do to use a email service for a same domain on other server

  11. 11

    How do I prevent Apache service from auto-starting on Linux?

  12. 12

    How do I Download the Symfony Distribution as Zip archive?

  13. 13

    symfony2中的MySQL(PDO)错误:驱动程序中发生异常:SQLSTATE [HY000] [1049]

  14. 14

    symfony2中的MySQL(PDO)错误:驱动程序中发生异常:SQLSTATE [HY000] [1049]

  15. 15

    使用 Symfony2 和 PDO_odbc 并使用服务和存储库进行连接和查询

  16. 16

    Symfony2 Adding 3rd party Bundles to a Service Controller

  17. 17

    Symfony2 phpexcel和service_xls5有问题

  18. 18

    Using Dependency Injection I find myself creating factories to do Unit Testing. Is this normal?

  19. 19

    How do I resolve ClassNotFoundException?

  20. 20

    How inject $stateProvider in angular application?

  21. 21

    ORDER BY 2参数PDO

  22. 22

    How do paths work in a Java deployed REST web service?

  23. 23

    Inject AngularJS 1.2 $location service into controller not working in PhoneGap 3.0

  24. 24

    在Spring MVC中使用@ Controller,@ Service和@Inject

  25. 25

    How can I enable or disable a windows service in .NET?

  26. 26

    Symfony2 PagerFantaBundle

  27. 27

    symfony2 createQueryBuilder

  28. 28

    路由symfony2

  29. 29

    Symfony2 registerBundles()

热门标签

归档