Created
September 8, 2014 07:41
-
-
Save reshadman/474ace3c9fa579e5f864 to your computer and use it in GitHub Desktop.
Multiple binding of a class
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 | |
class Session { | |
public function __construct(StorageInterface $storage) | |
{ | |
$this->storage = $storage; | |
} | |
} | |
class RedisStorage implments StorageInterface {} | |
class MemcachedStorage implements StorageInterface {} | |
class Session ServiceProvider extends LaravelServiceProvider { | |
public function register () | |
{ | |
$this->app->bind('session.redis',function($app){ | |
return new Session(new RedisStorage()); | |
}); | |
$this->app->bind('session.memcached',function($app){ | |
return new Session(new MemcachedStorage()); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment