Your SlideShare is downloading. ×
0
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Introduction to rg\injection
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to rg\injection

2,531

Published on

Presentation about rg\injection, a PHP dependency injection container which is inspired by google guice.

Presentation about rg\injection, a PHP dependency injection container which is inspired by google guice.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,531
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  1. rginjection Bastian Hofmann
  2. Questions? Ask!
  3. Dependency Inversion
  4. http://www.doolwind.com/blog/solid-principles-for-game-developers/
  5. Dependencies
  6. Dependency Injection
  7. Constructor
  8. Setter
  9. Method argument
  10. Constructing classes
  11. Make it easier with factories
  12. Dependency Injection Container
  13. What‘s out there?
  14. <?xml version="1.0" ?> <container xmlns="http://symfony-project.org/2.0/container"> <parameters> <parameter key="mailer.username">foo</parameter> <parameter key="mailer.password">bar</parameter> <parameter key="mailer.class">Zend_Mail</parameter> </parameters> <services> <service id="mail.transport"class="Zend_Mail_Transport_Smtp" shared="false"> <argument>smtp.gmail.com</argument> <argument type="collection"> <argument key="auth">login</argument> <argument key="username">%mailer.username%</argument> <argument key="password">%mailer.password%</argument> <argument key="ssl">ssl</argument> <argument key="port">465</argument> </argument> </service> <service id="mailer" class="%mailer.class%"> <call method="setDefaultTransport"> <argument type="service" id="mail.transport" /> </call> </service> </services></container>
  15. rginjection inspired by google-guice http://code.google.com/p/google-guice/
  16. Creating an instance of a class
  17. Automatic creation of dependencies through Typehints
  18. @inject
  19. What classes can be injected?
  20. No constructor
  21. Constructor without arguments
  22. Constructor with arguments that have default values
  23. Injectable constructor
  24. By the way: Property Injection
  25. Singletons with public static getInstance method following the same rules
  26. STOP: Don‘t use Singeltons
  27. Singletons are evil!
  28. Let the DIC take care of instances
  29. @singleton
  30. By the way...
  31. Passing additional, fixed values to instance
  32. What about testing
  33. Only test the class, not the dependencies
  34. Mocking
  35. Working with Interfaces
  36. Why interfaces?
  37. But we can not create an instance of an Interface!
  38. @implementedBy
  39. Mocking an interface
  40. Named @implementedBy
  41. What‘s that for?
  42. Providers
  43. @providedBy
  44. Method invocation at DIC
  45. Same rules
  46. And if you don‘t like annotations...... or want to integrate 3rd party code
  47. Integrate it into your framework
  48. Great! So, how does it work internally?
  49. Development: Reflection
  50. Production: Generated Factory Classes
  51. DEMO
  52. Available? very soon
  53. h"p://twi"er.com/Bas2anHofmannh"ps://profiles.google.com/bashofmannh"p://lanyrd.com/people/Bas2anHofmann/h"p://slideshare.net/bashofmannmail@bas2anhofmann.de

×