Laravel – Different between instance vs bind

use ->bind() when you want to provide just a FQCN (full-qualified class name), or a factory closure, to instruct the container on how to lazily build an instance only when needed.
use ->instance()` when you already have an constructed instance and want to instruct the container to provide that particular instance when required.

Simple Bindings

We can register a binding using the bind method, passing the class or interface name that we wish to register along with a closure that returns an instance of the class

Binding Instances

You may also bind an existing object instance into the container using the instance method. The given instance will always be returned on subsequent calls into the container

Leave a Reply

Your email address will not be published. Required fields are marked *

https://www.google.com/recaptcha/api.js?onload=wpcaptcha_captcha&render=6LcfOIUmAAAAAIGmuvjUI1UMleIKMckvA94vyQsj&ver=1.23