Slim framework comes with a Dependency Injection container called Set. The basics The DIC is accessed via the container property of $app. To set, you use the set() method: $app->container->set('foobar', function() { return new Foo\Bar(); } ); If you need a given resource to be shared, then use the singleton method: $app->container->singleton('foobar', function() { return new Foo\Bar(); } ); And th