Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kirkland's avatar

Using an API from a Service

Hey there all! Hope you're all doing well!

I was wondering if there was a best practice when using a third party API with Laravel. For example, if I wanted to use the official PHP Stripe API, is there a better way of using it other than including the file at the top of the controller?

API in question: https://github.com/stripe/stripe-php/releases

0 likes
2 replies
Francismori7's avatar
Level 52

Well for Stripe you should use Laravel Cashier, which is built for it. But, essentially, when using a library, you just import it at the top of the file and use it. Of course you can create service classes to wrap around it and use your own API to defer to the expected API, that way you can replace providers easily.

Kirkland's avatar

Ok, that seems like a reasonable answer. Are there any official Stripe repositories for services? I'm also going to need some for quite a few different social services as well as Amazon, Microsoft, and IBM cloud services.

Please or to participate in this conversation.