-
I'm planning on using Saloon to create a lib to interact with my own app. The lib can be used by other PHP (not Laravel) apps (consumer of the lib). How do I pass the base url and authentication details to the connector in the consumer app? Extending a base connector and setting the name of that connector in each request in the consumer app is not efficient. Great work BTW! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Thank you for the feedback! In my libraries/SDKs that use Saloon, I tend to define the base URL / authentication into the constructor of your SDK/Library class. Then you can create a new instance of a connector and pass it into the connector via a constructor. For authentication, you could accept an instance of Then you can re-use the same connector multiple times for the requests. |
Beta Was this translation helpful? Give feedback.
-
This is what I do in my Connectors:
|
Beta Was this translation helpful? Give feedback.
Thank you for the feedback!
In my libraries/SDKs that use Saloon, I tend to define the base URL / authentication into the constructor of your SDK/Library class. Then you can create a new instance of a connector and pass it into the connector via a constructor.
For authentication, you could accept an instance of
AuthenticatorInterface
or create one yourself and then authenticate the connector with$connector->withAuth()
.Then you can re-use the same connector multiple times for the requests.