Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
Created December 1, 2015 18:56
Show Gist options
  • Save jeremykendall/fbe401b85ef2914a57e9 to your computer and use it in GitHub Desktop.
Save jeremykendall/fbe401b85ef2914a57e9 to your computer and use it in GitHub Desktop.
Using Slim\Container::register()
<?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
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