I'm currently working on a new PHP RESTfulAPI for a project of mine. It builds on SLIM API 4 uses actions, services, and repositories. However, this architecture is new to me and I have questions that are hard to find good answers to.
The API The API has multiple repositories for handling communication with the database, e.g. for users, categories, and companies. However, I recently added a repository to handle uploaded files, and with it, functions like scaling, compressing, and rotating images. But this repository doesn't communicate with any database, it only communicates with another FTP server using SSH2.
Question starts here: But is this even a valid repository if it doesn't communicate with a database and has these functions? Should I split up the functionality into multiple services instead? This feels stupid due to the high amount of services it'll require unless I rewrite some of the functionality into a module or something similar.
Please let me know your thought on this and if I need to clarify anything. If you have any good reading, please share it with me.
CodePudding user response:
A repository maps the domain layer to the data access layer, the database. For this reason a FTP/SFTP/FTPS/HTTP etc. client is not a repository.