项目作者: dugajean

项目描述 :
Tiny IoC container with awesome autowiring & more - for your PHP project.
高级语言: PHP
项目地址: git://github.com/dugajean/pouch.git
创建时间: 2016-09-29T11:35:47Z
项目社区:https://github.com/dugajean/pouch

开源协议:MIT License

下载


Pouch

Build Status
Latest Stable Version
Total Downloads
License

Tiny IoC container with awesome autowiring & more - for your PHP project.

Requirements

Install

Via Composer

  1. $ composer require dugajean/pouch

Usage

You may register your whole src/ folder with this package in order to enable automatic resolution everywhere within the namespace

  1. <?php
  2. use Pouch\Pouch;
  3. Pouch::bootstrap(__DIR__);
  4. // ...
  5. pouch()->registerNamespaces('Foo'); // Foo corresponds to src/

You may now just typehint to the objects your method requires and it will be automatically resolved for you.

  1. <?php
  2. namespace Foo;
  3. class Bar
  4. {
  5. public function doSomething(Baz $baz)
  6. {
  7. $baz->doSomethingElse();
  8. }
  9. }
  10. class Baz
  11. {
  12. public function doSomethingElse()
  13. {
  14. echo 'From Baz!';
  15. }
  16. }

Constructor object arguments will also be automatically injected.

You can always manually bind data to the container using pouch()->bind($key, $dataClosure) and also resolve anything from the container using pouch()->get($key).

Read the wiki and the API docs for further information.

Testing

  1. $ vendor/bin/phpunit

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

Pouch is released under the MIT License.