Why does laravel IoC does not provisioning my class with my method?

I can’t get why laravel tries to create my class itself, without using my method. I can see that IoC binding is executed (POINT 1 is shown). But singleton method is being never executed. Why?

In my service provider (not deferred):

 * Register the service provider.
 * @return void
public function register()
    echo "POINT 1"; // I can see this one
    $this->app->singleton(AppServicesFooBar::class, function($app)
        echo "POINT 2n"; // Does not comes here
        return new FooBar($params);

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.