Any way to register a database client to the application command
Let's take this example:
It registers nice. Now let's say we register out DB client:
Now since I don't wanna create new instances everytime a command is invoked. I need a way to register this. (With type safety).
My question: How can I register the db client onto the context of the command?
Singleton class? Well, if there are no other possibilites. I'd rather just instantiate it in main and keep references to it throughout the commands where I can invoke.
Solution:Jump to solution
Attach it to the container https://sapphirejs.dev/docs/Guide/additional-information/using-and-extending-container
Sapphire Framework
Using and extending container | Sapphire
The container is a way in which Sapphire achieves Dependency Injection. This is a very useful feature, since it
1 Reply
Solution
Attach it to the container https://sapphirejs.dev/docs/Guide/additional-information/using-and-extending-container
Sapphire Framework
Using and extending container | Sapphire
The container is a way in which Sapphire achieves Dependency Injection. This is a very useful feature, since it