Composer create-project: Working with forked repository

I am using awesome WordPress stack Bedrock from Roots.IO for my WordPress projects. I created a fork from the original repository with a slight customizations to my specific situation, as the developers encourage us to do in their README file.

Recommended installing of Bedrock is done via Composer command composer create-project roots/bedrock which downloads the package from Packagist. This works, although I need to work with a forked version of it.

Read More

If I get the idea of Composer right, I have a few options:

Forked repository to Packagist

Submit my forked repository to Packagist. This is not recommended by Packagist, yet I’ve tried it with some odd results (I can elaborate if needed).

Create-project with custom repository-url

Run create-project command with --repository-url option set to URL of my forked repository. This did not work as well with following errors (both for original and forked repository):

$ composer create-project wpgrouse/wpgrouse-bedrock --repository-url:https://github.com/wpgrouse/wpgrouse-bedrock.git

The file https://github.com/wpgrouse/wpgrouse-bedrock/packages.json could not be downloaded.

Well, there is no such file in Bedrock.

Use the original repository and create modifications each time manually

This sucks for obvious reasons.


Can you help me with this headache? I posted the question to Bedrock GitHub as well, but as I am in extreme hurry with this, I would like to seek some help here as well.

Thank you in advance, Petr!

Related posts

Leave a Reply

2 comments

  1. Option 2 is definitely correct.

    You will need to create a repository for composer to pull your project informations from. The simplest solution is to use Satis made by the same folks that made Composer. Satis is a simple package repository generator (like a static Packagist).

    My satis.json looks like that:

    {
        "name": "Your Satis name",
        "homepage": "Url to your satis",
        "repositories": [
            { "type": "vcs", "url": "git@your-git-url:your-user/bedrock.git" }
        ],
        "require-all": true
    }
    

    My fork of bedrock is hosted on a private gitlab server, but I imagine that your url could be on github or bitbucket or anywhere else.

    You will then need to run satis so it create the repository. Refer the github repo on how to do that. Satis will spit out a folder containing your repository content. I hosted mine on a simple web server. Since it’s only html, I believe you can host it on github page or maybe even locally.

    You will then be able to call:

    composer create-project roots/bedrock --stability=dev --repository-url=http://your-statis-url <project_name>
    

    If you have questions, or need more details, don’t hesitate.

  2. For any google speeders, I’ve received my answer on GitHub from Bedrock creators.

    (option 2) should be correct but looks like the Composer documentation isn’t great for this feature.
    See: Composer create-project fails on local package repository, composer/composer#1899. Basically you’ll need to create a local packages.json somewhere that defines your fork and then use that packages.json as the –repository-url

    I would probably stick for cloning the repository manually for now, even though it’s not as shiny as just hitting create-project command.

    Also, I will leave this as an answer here if noone smarter comes.