1

I am a developer myself and I built extension for Magento 2. So far it is only zip package file. User just unzip the file, uploads it to ftp and then runs php bin/magento setup:upgrade. Now I need to create also Composer option for installation so our customers can install the extension without uploading zip files but using composer.

One of the problem is that we have some files outside app folder (inside pub and lib). More than 100 files. I think that composer doesn't have option to include files outside app folder because composer will install it in vendor folder.

Is it possible to include into composer also files from lib and pub folder?

2

If you really need the files in these locations, you will need a second composer package of the type "magento2-component" instead of "magento2-module". The module then depends on the component so that both are installed.

In the component's composer.json you can specify which files in the package should be copied where into the project. Take a look at magento/base to see how it works.

For example, this is a composer.json to copy everything in "src" into "pub", as well as into the root directory (for installations that do not use "pub" as document root)

{
  "name": "example/example",
  "type": "magento2-component",
  "extra": {
    "map": [
      [
        "src/*",
        ""
      ],
      [
        "src/*",
        "pub"
      ]
    ]
  }
}
  • You haven't happened to find any documentation on this subject have you? It's all fun and games running through the types of each of the core packages and seeing the types they use, but it's not necessarily clear when to use which, ie magento2-component, magento2-library, magento2-module. To make things worse of course the documentation then adds in other things like metapackage. (see devdocs.magento.com/guides/v2.2/extension-dev-guide/prepare/…) Oh the joys.. – Nathaniel Rogers Aug 28 '18 at 7:14
  • 1
    I hate to add these as comments, I just found some wonderful documents regarding how these types are processed under the magento/magento-composer-installer package's README.md, makes sense that it's handled by that. All the information is clear and available at <magento2>/vendor/magento/magento-composer-installer/README.md – Nathaniel Rogers Aug 28 '18 at 7:20
0

You can keep all the folders/files in Vendor and create symlinks to those in lib or pub folders. Many of the extensions do this.

  • Thank you for the idea. But this would be even more complicated for our customers I guess, it would require server administrator to create symlinks, correct? – JohnyFree Jan 22 '18 at 11:58

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.