2

I have the following structure:

app/code/Vendor/Module/....

app/design/adminhtml/Vendor/mythemename/...

In my composer.json I put something like this:

{
  "name": "vendor/module",
  "description": "A Magento 2 module that ...",
  "type": "magento2-module",
  "version": "1.0.0",
  "authors": [
    {
      "name": "Iunia ",
      "email": "iunia@test.com"
    }
  ],
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "100.0.*",
    "vedor/mythemename": "100.0.*"
  },
  "autoload": {
    "files": [ "registration.php" ],
    "psr-4": {
      "Vendor\\Module\\": ""
    }
  }
}

How do I package it so that it includes the module and the theme? It doesn't like the theme. Using validate_m2_package.php I get the following error:

More than one top-level directory detected, number of directories = 3. Top level directory expected to be the module directory.

Do I need to put "type": "metapackage", in my composer.json?

If the answer is yes, how should my composer.json look? Thank you in advance!

2

In the end I had to create 2 composer.json files, so two packages, one for a magento-module:

app/code/Vendor/Module/....

and the other for a magento-theme

app/design/adminhtml/Vendor/mythemename/...

My files look like this:

app/design/adminhtml/Stannp/backend/composer.json

{
  "name": "stannp/backend",
  "description": "Extends the Magento backend theme to add the Stannp logo in the admin panel",
  "require": {
    "magento/theme-adminhtml-backend": "~100.0"
  },
  "type": "magento2-theme",
  "version": "1.0.1",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "autoload": {
    "files": [ "registration.php" ]
  }
}

and:

app/code/Stannp/DirectMailing/composer.json

{
  "name": "stannp/directmailing",
  "description": "A Magento 2 module that connects to Stannp.com API",
  "type": "magento2-module",
  "version": "1.0.0",
  "authors": [
    {
    "name": "Stannp Ltd",
    "email": "email1@stannp.com",
    "website": "https://www.stannp.com/"
    },
    {
      "name": "Iunia",
      "email": "iunia@test.com"
    }
  ],
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "stannp/backend": "1.0.0",
  },
  "autoload": {
    "files": [ "registration.php" ],
    "psr-4": {
      "Stannp\\DirectMailing\\": ""
    }
  }
}

Please note: In my Stannp/backend/composer.json I have "magento/theme-adminhtml-backend": "~100.0" and in my Stannp/DirectMailing/composer.json I put the version from the Stannp/backend/composer.json in the require section. Also, the name used to require the theme is stannp/backend.

Also, when creating a package, you have to do something like this:

zip -r stannp_directmailing-1.0.0.zip Block/ Model/ Controller/ Helper/ Model/ Setup/ etc/ composer.json  registration.php view/

from inside app/code/Stannp/DirectMailing/ (!! very important), same process applies for the theme (so from inside of app/design/adminhtml/Stannp/backend/ folder)

Another important thing to mention is that I added my theme package as a shared package:

enter image description here

And then added it as a shared package to my extension:

enter image description here

Hope this helps someone else too. Cheers!

P.S. You can also add the content of the theme as a library (fonts, etc).

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.