Created
December 1, 2015 18:56
-
-
Save jeremykendall/fbe401b85ef2914a57e9 to your computer and use it in GitHub Desktop.
Using Slim\Container::register()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Assumes $yourExistingPimpleContainer is an instance of Pimple\Container | |
$provider = new YourContainerProvider($yourExistingPimpleContainer); | |
$container = new \Slim\Container(); | |
$container->register($provider); | |
// The Slim Container should now contain all the services from your existing container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Pimple\Container; | |
use Pimple\ServiceProviderInterface; | |
final class YourContainerProvider implements ServiceProviderInterface | |
{ | |
public function __construct(Container $yourExistingPimpleContainer) | |
{ | |
$this->container = $yourExistingPimpleContainer; | |
} | |
public function register(Container $pimple) | |
{ | |
foreach ($this->container->keys() as $key) { | |
$pimple[$key] = $this->container->raw($key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment