S
S
Sergey Ilichev2021-01-11 20:29:56
PHP
Sergey Ilichev, 2021-01-11 20:29:56

Architecture question, how to implement a connector class for an api of a third-party service?

Hello. I have an architecture question. Preferably with an eye on the Onion architecture and some framework, for example yii2.

Let's say there is a need to connect to a third-party api service to process some data. We have the SuperServiceConnector class, which has methods for working with the api of this service. So, to access this service, the key is used, which is given to me when registering for the service, plus the url api. Is this data stored in the database? If in the database, then where and how is it more correct to get access to them? After all, our connector is not ActiveRecord and is not connected to the database. Or it is possible to simply register in separate configs? Type in params to add?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danbka, 2021-01-11
@Danbka

The key and URL can be stored in env.

D
dmitriy, 2021-01-11
@dmitriylanets

onion uses layering with at least three layers:
Domain - your Entity, RepositoryInterface, Service
Application - business logic of the application
Infrastructure - implementation of contracts, drivers, Repository

Допустим есть необходимость коннектиться к стороннему api сервиса для обработки каких-то данных

what you described is the infrastructure, where you store it and how it is your business, the configs can be in the ini file, they can be in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question