usox / circulon
A PHP dependency resolver
Installs: 64 936
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.5
Requires (Dev)
- php: >=5.5
- phpunit/phpunit: ^4
This package is auto-updated.
Last update: 2024-11-06 01:33:02 UTC
README
Requirements
To use Circulon in your projects, you will just require PHP 5.6 or later.
Composer install
You can install this package by using Composer. Link to Packagist: https://packagist.org/packages/usox/circulon
composer require usox/circulon
Usage
Simply add your dependencies as follows:
$resolver = new \Usox\Circulon\Circulon(); $resolver ->addDependency('foo', 'bar') ->addDependency('foobar', []) ->addDependency('baz', []) ->addDependency('bar', ['baz', 'foobar']);
Calling resolve()
will return the dependencies in order.
$list = $resolver->resolve(); var_dump($list); array(4) { [0] => string(3) "baz" [1] => string(6) "foobar" [2] => string(3) "bar" [3] => string(3) "foo" }
Circular dependencies
$resolver ->addDependency('foo', 'bar') ->addDependency('bar', 'baz') ->addDependency('baz', 'foo'); $resolver->resolve();
Circulon detects the circular dependency and throws a CircularDependencyException
with message Circular reference for baz => foo
.