0

I have created a private composer package in packagist.com but when I use composer require command to fetch it. My package coming under vendor folder which is on root.

But I want it to be in app/code folder. Is there any parameter for composer.json where I can set app/code, so it will come under app/code/.

Sintu Roy
  • 155
  • 9

2 Answers2

0

Yes there is. According to the composer documentation, if your project uses the PSR-4 specification for loading classes, then adding the snippet below to the composer.json file would work.

NB: You will need to change ProjectNameSpace to the base namespace for your project.

...
  "autoload": {
    "psr-4": {
      "ProjectNameSpace\\": "app/code"
    }
  },
...
Goke Obasa
  • 4,328
  • 1
  • 18
  • 26
0

Theoretically. You can't composer will always place the code in vendor directory. The code is external and therefore can be updated only by composer. It must not be in app/code as only code you modify for the project should be in app/code.

If you wish to make a Magento project, you should have the fallowing files in the versioning tool.

  • app/*
  • composer.json
  • composer.lock
  • .htaccess
  • index.php

The other files will be handled by composer.

But if you really need to do it, but I don't see any reason to do so, then you could use a post-update & post-install script to move the code. But it's a very bad idea.