Skip to content
Tiny IoC container with awesome autowiring & more - for your PHP project.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
tests
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
composer.json
helpers.php
phpunit.xml
sami.php

README.md

Pouch

Build Status Latest Stable Version Total Downloads License

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

Requirements

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.

You can’t perform that action at this time.