gitcomposer-phpgitlabgit-submodulessatis

composer private package based on gitlab is identified as git submodule


I made some private packages for composer on company's gitlab. But when require my private package on other project,it is identified as a git submodule,so I can't push it to the production environment.

I follow composer document to alter my project's composer.json.
I also try the Satis,but it turn on the same result---submodule.

When I store the package on Github, It works well!

It's the gitlab's issue?
Thanks!


Solution

  • Composer is cloning your packages with git instead of downloading them. When composer downloads a package from github via packagist, it downloads an archive of the file (.tar.gz), then uncompresses it into your vendor directory. When it gets your private repository, it can't find an archive, so it clones it directly with git. This clone will have a .git directory, just like a normal cloned repository.

    The typical solution is to add the vendor/ directory to your .gitignore. However, if you have special circumstances, you can get around this by creating your own archives with satis.

    From the satis docs:

    {
        "archive": {
            "directory": "dist",
            "format": "tar",
            "prefix-url": "https://amazing.cdn.example.org",
            "skip-dev": true
        }
    }
    

    If you do this, your packages will be archived before they are installed in the vendor directory. There will be no .git directory, so it won't be treated as a submodule.