Deploy content of pub folder using composer when installing a new Magento 2 module

by Michel Gokan   Last Updated May 29, 2017 09:09 AM

There are many modules that require to copy some files and folder inside the magento's "pub" folder. As our entire modules operations and infrastructure is based on composer, this manual (non-composer) copy/paste (merge) of pub folder is making a real pain for automation process ( I know we can use rsync command but I really wanted to do all operations based on composer from our private Satis repo, just don't like to manually copy paste contents of our pub folder to magento's pub folder).

I already tried composer's map functionality but as we are using "Composer Custom Directory Installer" plugin for composer to install some 3rd party modules in app folder (as they are not working when installed under vendor folder), so map functionality is not work as expected.

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "version": "2.0.7",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
   "repositories": [
        {
            "type": "git",
            "url": "https://github.com/mnsami/composer-custom-directory-installer.git"
        },

        {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopblog.git"
        },
          {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopall.git"
        },
         {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopbasewidget.git"
        }
        ,
         {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshoppagebuilder.git"
        },
        {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopmegamenu.git"
        },  
        {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopproductlist.git"
        },  
        {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopsetup.git"
        },
        {
            "type": "git",
            "url": "https://[email protected]/rmecommerce/oshopthemesettings.git"
        },      
        {
          "type": "git",
          "url": "https://[email protected]/rmecommerce/landryandarcaritheme.git"
        },
        {
        "type": "git",
        "url": "https://[email protected]/rmecommerce/base.git"
        },
        {
        "type": "git",
        "url": "https://[email protected]/rmecommerce/oshoptheme.git"
        },
        {
        "type": "git",
        "url": "https://[email protected]/rmecommerce/pub.git"
        },
        {
        "type": "git",
        "url": "https://[email protected]/rmecommerce/landryandarcaripub.git"
        }



    ],
    "require": {
        "magento/product-community-edition": "2.0.7",
        "composer/composer": "@alpha",
        "mnsami/composer-custom-directory-installer": "*",
        "Ves/Blog":"*",
        "Ves/All":"*",
        "Ves/BaseWidget":"*",
        "Ves/PageBuilder":"*",
        "Ves/Megamenu":"*",
        "Ves/Productlist":"*",
        "Ves/Setup":"*",
        "Ves/Themesettings":"*",
        "magento/theme-frontend-oshop": "*",
        "magento/theme-frontend-base": "*",
        "magento/theme-frontend-Landryandarcari": "*",
        "RMI/pub":"*",
        "RMI/landry-arcari-pub":"*"

    },
    "require-dev": {
        "phpunit/phpunit": "4.1.0",
        "squizlabs/php_codesniffer": "1.5.3",
        "phpmd/phpmd": "2.3.*",
        "pdepend/pdepend": "2.2.2",
        "sjparkinson/static-review": "~4.1",
        "fabpot/php-cs-fixer": "~1.2",
        "lusitanian/oauth": "~0.3 <=0.7.0"
    },
    "config": {
        "use-include-path": true
    },
    "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/",
            "Magento\\": "app/code/Magento/"
        },
        "psr-0": {
            "": "app/code/"
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
        }
    },
   "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "magento-force": "override",
        "installer-paths":{
      "./app/code/Ves/Blog/": ["Ves/Blog"],
      "./app/code/Ves/All/": ["Ves/All"],
      "./app/code/Ves/BaseWidget/": ["Ves/BaseWidget"],
      "./app/code/Ves/PageBuilder": ["Ves/PageBuilder"],
      "./app/code/Ves/Megamenu/": ["Ves/Megamenu"],
      "./app/code/Ves/Productlist/": ["Ves/Productlist"],
      "./app/code/Ves/Setup/": ["Ves/Setup"],
       "./app/code/Ves/Themesettings/": ["Ves/Themesettings"],


      "./app/design/frontend/Venustheme/oshop/": ["magento/theme-frontend-oshop"],
      "./app/design/frontend/RMI/Base/": ["magento/theme-frontend-base"],
      "./app/design/frontend/RMI/LandryAndArcari/": ["magento/theme-frontend-Landryandarcari"]

    }
    }
}

My goal is to install (merge) content of my module's pub folder with Magento 2's root pub folder when using composer require mynamespace/mymodulename command.

Any help would be appreciated.



Answers 1


I hope I understand your question correctly. Your problem is that some of modules your modules bring files for the magento pub folder with it.

But all module specific files should be inside of the specific module directory (including images, less/css, js, email-templates, knockout-js templates, translations etc). Using 'setup:static-content:deploy' deploys your modules static content, aswell as compile the modules less files to css files etc.

composer require mynamespace/mymodulename

php bin/magento module:enable MyNamespace_MyModulename

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy en_US
juhanix
juhanix
May 29, 2017 08:40 AM

Related Questions


Modules/Extensions installed via Composer Problem

Updated August 03, 2017 19:09 PM

Use plugin to modify content of catalog tab

Updated July 15, 2015 13:04 PM

Magento extension not showing up in back-end

Updated October 03, 2017 09:09 AM


Payment and Shipping Method Filtering - Magento 2

Updated July 05, 2018 12:09 PM