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

alireza_hadizadeh's avatar

What is the best architecture in Laravel for handling features that rely on external APIs (some with authentication, some without)?

I have an existing Laravel e-commerce project that uses an external SMS provider for sending OTP codes and notifications. The provider offers a full API for its own panel, and I want to integrate parts of that panel directly into my e-commerce admin dashboard to improve convenience for my clients (companies and start-ups who buy the project).

Inside my app I already send SMS through a simple service class using pattern/template codes triggered by events. But now I want to add additional features from the provider’s panel into my dashboard, such as:

  • Reports of sent messages
  • Checking SMS balance
  • Sending marketing SMS
  • Managing pattern/template codes
  • Other API-based features

My question is about project structure. Since this is becoming a complete “SMS panel” inside my dashboard, what is the best architectural approach?

Should I:

  1. Create a separate package so I can reuse it in other projects?
  2. Use a module system like nwidart/laravel-modules to organize it as an isolated module?
  3. Apply Domain-Driven Design and treat SMS as its own domain?
  4. Or build it as a separate project and use a subdomain (though this defeats my goal of keeping everything in the same dashboard)?

If anyone has integrated a third-party service panel into their Laravel admin before, how did you structure it?

Also, for future projects where a feature is fully API-based: Is Laravel still a good choice for building the dashboard for such features, or is it better to use a frontend framework like React or Vue (even though I don’t currently have experience with them)?

1 like
3 replies
vincent15000's avatar

Hello, I'll try to answer your questions.

  1. Only if you think that it can be useful and reusable in other projects.

  2. Could be a good idea ... but why with an external package ? you can do that without any package.

  3. Seems to be like a similar approach as 2.

  4. Seems to be like a similar approach as 1.

Yes Laravel is still a good choice for building a full API application. But I'm not sure what you are trying to do ... if an application is a full API one, that means that you don't have any frontend and only provide services (via the API) to developers.

If your application is a full API one, then yes you need to use a frontend like React, VueJS, ... And you have 2 choices : develop the frontend inside the Laravel project or develop the frontend as a separate application.

martinbean's avatar

@alireza_hadizadeh If I were to build this, I’d extrapolate “functionality” from the actual provider, and then create something driver-based.

Think about Laravel’s mail component: regardless of which driver you’re using (SMTP, Mailgun, SES, etc), your code shouldn’t change and you just use the same methods (e.g. Mail::to($someone)->send(new FooMailable())). I’d do the same for SMS.

You can then also use interfaces to declare what functionality a particular SMS vendor provides. So I’d have interfaces for things that some vendors may offer and others may not; interfaces like GeneratesReports, ChecksBalance, SupportsTemplating, and so on. If the initial vendor you’re working with supports all of these then that’s great; you just implement all of the interfaces. But you may find you want to swap, and support additional, vendors in the future, and alternative vendors may not support all of these features. So you can implement only the interfaces corresponding to the functionality that particular vendor does support.

This should mean you don’t have to change any implementation code in your admin panel, as your admin panel should just be using some sort of wrapping manager class or façade to call methods (Sms::getReport(), Sms::getBalance(), etc), but that manager/facade calls the correct implementation based on configuration the same way Laravel’s components for cache, mail, queue, session, etc. do.

1 like
jlrdw's avatar

Is Laravel still a good choice for building the dashboard for such features

Back end part yes.

But it helps if you explain exactly what the API is for. There are hundreds of ways people do API's.

Also do you even need an API. I have seen so many questions on API's where a regular web app that's mobile friendly would be better suited.

Most API's, not including a mobile app, you aren't even concerned with a front end, the user of the returned JSON handles that.

They could be using:

  • PHP
  • Another PHP framework
  • A java technology such as Spring Framework
  • .Net Core
  • etc

All of this has to be considered.

You main job is working out the instructions to use your API.

But normally if you aren't having a mobile app, then a regular web app works.

An example of an API would be a doctors office getting lab results from a lab. In such a case a developer would have written the code to deal with the JSON data for display.

But it sounds like you are using other API's, in such a case, what to use is subjective. I use either Fetch JS or Axios JS. But I suggest some tutorials on using an API and the different methods, like Curl and the many others. There are many ways (technologies) to in turn display the data.

1 like

Please or to participate in this conversation.