0

As I can see the standard Magento 2 convention is for each module to obtain its own API folder which is responsible for CRUD operations. However, I want to discuss this a little bit. I want to create an API Module which contains only and all of the REST functionality of my whole project, because I don't like the Idea of each module to carry a separate folder with separate files for the 2 API calls that the module needs (A lot of unnecessary folders and files in my opinion). Does the Magento Framework allows that and if it does, will this have any downside besides the fact the for all my modules to work I will need to have ApiModule installed and enabled.

1

As I can see the standard Magento 2 convention is for each module to obtain its own API folder

Its not required, your module may not have API. For example you can only extend functionality of other module.

which is responsible for CRUD operations

API provides interfaces for use by external modules. CRUD operations is particular case and low-level representation of API. For example you can provide interfaces for (create/read/update/delete) orders of height level commands like (place/refund/invoice/) related to business needs.

I want to create an API Module which contains only and all of the REST functionality of my whole project, because I don't like the Idea of each module to carry a separate folder with separate files for the 2 API calls that the module needs (A lot of unnecessary folders and files in my opinion).

Its look like Facade pattern for hide internal private modules interaction.

But you should aim to creating single responsible modules with own APIs. This approach will simplify support and incremental improving of your module.

For example, when one of your modules will be changed, you will be forced to increase version your aggregated ApiModule module according semver and its badly for clients, which use other part of this module.

Maybe, if your cannot create individual sensible API for your module, but can for group modules, looks like:

  • You have group of modules, which extension one main module and you need to add API to main module.
  • Was used wrong module splitting

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.