Dependency injection with PHP

1,099 views

Published on

Speaker: Nikita
Work at: CocCoc

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,099
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
111
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Dependency injection with PHP

  1. 1. Dependency Injection with PHP Nikita Groshin Nguyễn Huy Tuấn
  2. 2. Itim More than 200 employees More than 80 developers from different countries Different programming languages and paradigm Java, C++, PHP, JS, Python etc
  3. 3. Frontend and Tools Deprtment 13 members PHP, JS, Python Kohana, Zend Framework 100% Zend Certificated developers
  4. 4. Core Products Search engine http://coccoc.vn/ Browser http://corom.vn Not only
  5. 5. "Developers! Developers! Developers""Dependency! Dependency! Dependency"
  6. 6. Dependencies are suck? NO. They are useful! Hard code is suck
  7. 7. Good Dependency
  8. 8. Bad Dependency
  9. 9. Bad
  10. 10. Better
  11. 11. Good
  12. 12. Dependency Injection are simple.
  13. 13. Bad
  14. 14. Good
  15. 15. Injection types Constructor injection Setter injection Interface injection
  16. 16. Interface Injection
  17. 17. Interface injection
  18. 18. Quite easy.But why to use it?
  19. 19. Hard coded dependency Hard to reuse Poor isolation Hard to test A lot of code Hard to maintain Hard to understand
  20. 20. Dependency injection Loose coupling Reuse of code Reduce amount of code Clear and Understandable Extremely easy to test
  21. 21. Dependency injection Loose coupling Reuse of code Reduce amount of code Clear and Understandable Extremely easy to test
  22. 22. Extremely easy to test
  23. 23. Manual Di management is complicated.
  24. 24. We need container!
  25. 25. Disclaimer Dependency Injection != DI container DI container use Service Locator Anti-Pattern DI container make code less native Powerful tool – use careful Often Manual injection is enough
  26. 26. How many lines of code we need for simple DI container?
  27. 27. Twittee http://twittee.org/ Packed in less than 140 characters, it fits in a tweet. Author Fabien Potencier Production ready
  28. 28. Twittee source
  29. 29. Pimple http://pimple.sensiolabs.org/ 50 lines of code Full functionality Author Fabien Potencier Production ready
  30. 30. Questions? job.coccoc.vn nike-17@coccoc.vn

×