1

I am implementing a project that I want to share via Packagist. Usually, the composer.json file would be in the project root directory, but I want to have all the composer-related files and directories under the subdirectory /private/composer. After moving composer.json, composer.lock and vendor, Packagist is not able to find the composer.json on my remote repository, so my project will not auto-update anymore.

Is it possible to do what I want and still have Packagist auto-updating the project?

The project structure I want to achieve is like this:

.
├── .editorconfig
├── .git
│   ├── branches
│   ...
├── .gitignore
├── .htaccess
├── license.txt
├── private
│   ├── composer
│   │   ├── composer.json
│   │   ├── composer.lock
│   │   └── vendor
│   │       ├── autoload.php
│   │       ...
│   ├── npm
│   │   ├── package.json
│   │   ├── package-lock.json
│   │   └── node_modules
│   │       ...
├── public
│   └── index.php
└── readme.md
Joan Botella
  • 315
  • 1
  • 2
  • 14

2 Answers2

2

No, it is not possible.

Moreover, even if it was possible, I would not recommend it - this is unusual configuration and it would only confuse users of your package.

rob006
  • 21,383
  • 5
  • 53
  • 74
  • 2
    I think it is more confusing to have lots of configuration files on your project root directory. If I wanted to have this project on several package managers it would be a mess. I will post on that issue asking for supporting this. Thanks. – Joan Botella Feb 03 '20 at 09:47
  • Where does the given file structure contain "lots of configuration files"? And why is that confusing? – Nico Haase Mar 03 '20 at 15:23
  • @NicoHaase A regular project may contain several files of different kind in its root directory. For example, I have a readme.md, a license.txt, a .gitignore, an .editorconfig, a .htaccess, a .git subdirectory and my IDE configuration subdirectory. I prefer not to add more files to this mess. Also, I may like to add my project to other package managers now or in the future, so I want to keep things organized. Using composer will add a composer.json, a composer.lock and a vendor directory: I think it will be interesting to store them into a "composer" subdirectory, somewhere in my project. – Joan Botella Mar 13 '20 at 09:38
-1

it is possible with a little workaround:

just place a composer.json similar to this one in the project root:

{
    "type": "project",
    "name": "my/package",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "scripts": {
        "post-create-project-cmd": [
            "rm -rf composer.json vendor",
            "composer install -d path/to/folder/with/composer.json/in/it"
        ]
    }
}
Andreas Linden
  • 12,489
  • 7
  • 51
  • 67