2

I have created custom module without composer.json and my module working good,

Module Structure (Attached the screen shot here) :

enter image description here

What are all the disadvantages of creating custom module without composer.json file ?

1

Composer.json is used for the dependency manager for PHP. It also allows you to specify the project dependency for the module. The disadvantage of creating module without composer.json is suppose if you have depedency to third-party modules which you have added and then you give the package to another developer then he/she doesn't know which dependency you need to install. so if you have the composer.json then you can easily add to the root composer and run the composer update to install all the dependent module which are required for your module. Hope it clarify your question. Let me know if you have any other question Thanks

| improve this answer | |
0

Why we used composer.json ?

Magento 2 uses Composer, a PHP dependency manager, to package components and product editions.

Composer reads a composer.json file in Magento’s root directory to download third-party dependencies listed in the file.

The Component Manager uses the composer.json file in an extension’s root directory to perform the following actions:

The Component Manager can update, uninstall, enable, or disable an extension if installed using Composer (including from Packagist, Magento Marketplace, or other source) and it has a composer.json file. The Component Manager can still enable or disable an extension not installed using Composer (e.g. custom code) if it has a composer.json file.

Magento recommend you include composer.json in your component’s root directory even if you do not intend to distribute it to other merchants using Magento.

The composer.json file allows specifying the name, requirements, version, and some of other basic information about the component you are concerning. However, you need to save this file in the root directory of the module.

Click here to more

| improve this answer | |

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