Skip to content

Instantly share code, notes, and snippets.

@moufmouf
Forked from mnapoli/DI containers summary.md
Last active December 20, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moufmouf/6163791 to your computer and use it in GitHub Desktop.
Save moufmouf/6163791 to your computer and use it in GitHub Desktop.

DI containers usage comparison

DI containers are sorted alphabetically.

Submit PR to expand.

Comparison:

Container Read Test Not found behavior ArrayAccess
Aura DI get($key) has($key) Exception No
Auryn make($key, [$params]) Exception No
AWS/Guzzle get($key, [$throwAway]) ? Yes
Laravel make($key, [$params]) bound($key) Exception? Yes
League\Di build($key) bound($key) Exception No
Mouf get($key) has($key) Exception No
Orno\Di resolve($key, [$args]) ? No
PHP-DI get($key, [$useProxy]) Exception No
Pimple array access array access Exception Yes
PPI get($key, [$bool]) hasOption($key) Exception Yes
Symfony get($id, [$invalidBehavior]) has($key) Null or Exception No
ZF2 get($key, [$params]) Null No

Parameters surrounded by [] (like get($key, [$param])) are optional parameters.

Summary

  • Read method name:
    • get: 7
    • make: 2
    • build: 1
    • resolve: 1
    • array access: 1
  • Read mandatory number of parameters is always 1
  • Test existence:
    • with: 7
    • without: 5
  • Test existence method name:
    • has: 3
    • bound: 2
    • hasOption: 1
    • array access: 1
  • Not found behavior:
    • exception: 9
    • null: 2
  • ArrayAccess:
    • no: 8
    • yes: 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment