Hey
So I'm working on a slightly tricky problem right now. Basically I have an Application file which is handling logic to upload files to a selection of different providers like S3, Rackspace, etc.
I have a series of stubs for the file upload logic but these do not use the same methods for uploading a file. One uses uploadFile, another uses upload, and another uses send.
My understanding is that I should write an adapter interface so that I can always use the same function, and just swap out the implementation when I want to.
So I've written some code like this:
use \Interfaces\UploadInterface as UploadInterface;
class ftpAdapter implements UploadInterface
{
private $ftp;
function __construct(FTPStub $ftp)
{
$this->ftp = $ftp;
}
public function upload($file)
{
$this->ftp->uploadFile($file);
return 'Uploading FTP file';
}
}
I've added my Interfaces folder into my composer autoload. But whenever I run my script I get a Not Found error for the interface. What's the issue?
Secondly, I'm wondering if my structure is good here? I'm aiming to have the app receive a POST request from a form and then select which of the upload stubs it will use. It can potentially use multiple.
Is coding all of these to an interface and then use polymorphism to select the appropriate option a good way to go about it?