Search code examples
phpcomposer-phprepository

Can I include a composer.json file in the download package of the dependency-free PHP library project that I maintain?


I maintain a small, single-file PHP library that has no dependency. The library is not on Packagist but there is a Composer-type repository on my server with a packages.json file and zip files of download packages of various versions of the library. I now want to include a composer.json file in the library's download package. Since the library has no dependency, the composer.json only declares the repository information of the library itself. My goal is to facilitate Composer-based update of the library by maintainers of projects that use the library. Is this goal achieved without any problem by including the composer.json file?

{
    "name": "my/myLib",
    "type": "library",
    "require": {
        "php": ">=4.4"
    },
    "repositories": [
        {
         "type": "composer",
         "url": "myUrl"
        },
        {
         "type": "composer",
         "url": "myUrlAlt"
        },
    ]
}

cross-posted on Composer project site


Solution

  • Of course you can, this is not unusual case.

    PHPStan does that: https://github.com/phpstan/phpstan/blob/1.8.1/composer.json