Skip to content

Instantly share code, notes, and snippets.

@devmsh
Created June 22, 2017 17:46
Show Gist options
  • Select an option

  • Save devmsh/a622df456a6cc70ca2a95aa0d08b382e to your computer and use it in GitHub Desktop.

Select an option

Save devmsh/a622df456a6cc70ca2a95aa0d08b382e to your computer and use it in GitHub Desktop.
<?php
class Container
{
public function make($className){}
public function register($className, $callback){}
}
// initialize the container and register some classes
$c = new Container();
$c->register(FacebookSDK::class,function(){
return new FacebookSDK([
"app_key" => env('FB_APP_KEY'),
"app_secret" => env('FB_APP_SECRET')
]);
});
// let the container return some registered classes (e.g. within the controller)
$fb = $c->make(FacebookSDK::class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment