8
public function register() {
    $this->app->singleton('Qwerty', function ($app) {
        return new QwertyManager();
    });
}

This is what my singleton class looks like now i want to reset the singleton object or destroy its instance via laravel. I am using 5.3

jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107
ujwal dhakal
  • 2,289
  • 2
  • 30
  • 50

1 Answers1

16

You can call forgetInstance() on the service container to remove it. As the doc's say, this method can be used to Remove a resolved instance from the instance cache.

App::forgetInstance('Querty');

Next time you'll try to get an instance of this service from the container, it will be re-created using the function you provided in the singleton() method.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107