dugajean / pouch
Tiny IoC Container with automatic resolution for your PHP project.
Installs: 343
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/dugajean/pouch
Requires
- php: ~7.1
- ext-json: *
- psr/container: ^1.0
- psr/simple-cache: ^1.0
- symfony/finder: ^4.3
Requires (Dev)
- phpunit/phpunit: 6.5.13
Suggests
- ext-apcu: Enabling APCu will enhance the performance of Pouch in case no other cache store is available.
README
Tiny IoC container with awesome autowiring & more - for your PHP project.
Requirements
- PHP 7.1+
- PSR-4 standard with Composer
Install
Via Composer
$ 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
<?php use Pouch\Pouch; Pouch::bootstrap(__DIR__); // ... 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.
<?php namespace Foo; class Bar { public function doSomething(Baz $baz) { $baz->doSomethingElse(); } } class Baz { public function doSomethingElse() { echo 'From Baz!'; } }
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
$ vendor/bin/phpunit
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
Pouch is released under the MIT License.