V
V
vitaly_742019-08-05 01:56:02
Laravel
vitaly_74, 2019-08-05 01:56:02

How to implement package attachment to laravel via interface?

Good afternoon, I will describe the problem in more detail with an example.
There are 2 packages that perform similar functions (they are engaged in transcoding images, for example)
pack1 u pack2, how to quickly and famously change them in the system (without creating a factory, the factory does not suit me), using the "adapter" pattern, roughly speaking, simply replacing pack1 on pack2 and at the same time so that the system does not break.
And in general, is it necessary to provide for the rest of the packages at all in the future?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Vasilkov, 2019-08-05
@gzhegow

If it helps you, then I understand the interfaces in this way:
These are the names of some pieces of the program, about which you can explain even to the director.
As a bonus, the interface also checks the functionality. From this it follows that our task is to set the container of dependencies to the setting that if an interface is thrown at the input of the constructor, we must create an object attached to it.
Since you have two libraries and do the same thing, you need a wrapper class that, like a switch, can turn on the first or second, and then, when calling the method, pass it to the executor on which the switch is now
As a result, you will have two interfaces. One for the wrapper with the switch method, the second for the functionality. You can do without a wrapper interface, then you won’t be able to make an abstract switch for any thing in the program, you will write a new coass for each switch

A
Andrey, 2019-08-05
@VladimirAndreev

app()->make(\App\ServiceA::class)
app()->make(\App\ServiceB::class) Store the
argument in the database and switch in the interface

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question