Skip to content

Instantly share code, notes, and snippets.

@wimvds
Last active May 19, 2023 13:33
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wimvds/7150868 to your computer and use it in GitHub Desktop.
Save wimvds/7150868 to your computer and use it in GitHub Desktop.
Test an existing composer project (create-project) locally

First, clone the repository of the project :

  mkdir /tmp/project-name
  git clone ...

Create a packages.json file in the root, containing the following :

{
    "package": {
        "name": "vendor/project-name",
        "version": "1.0.0",
        "source": {
          "url": "/tmp/project-name/.git",
          "type": "git",
          "reference": "master"
        }
    }
}

Make your changes (and commit them), then test them locally :

composer create-project --repository-url=/tmp/project-name/packages.json vendor/project-name

To override some repositories with local copies (for testing commits/tags before you push them) you can add the following snippet in your composer.json (reference can be any branch):

    "repositories": [
        {
            "name": "kunstmaan/pagepart-bundle",
            "type": "git",
            "url": "/path/to/KunstmaanPagePartBundle/.git",
            "reference": "master"
        },
        {
            "name": "kunstmaan/utilities-bundle",
            "type": "git",
            "url": "/path/to/KunstmaanUtilitiesBundle/.git",
            "reference": "master"
        }
    ],
@lucien144
Copy link

Hey, thanks for this, it's really helpful. There's one more thing I reckon is good to mention. Sometimes the git repo is cached by composer and there's no other way how to force composer to read data from the local path other than call composer clearcache prior to calling the composer create-project.

@uniquename
Copy link

Very helpful, thx! Also the hint about composer clearcache. I found the cache for a particular repository in ~/.composer/cache/vcs/path-to-repo-repo-name.git/. Deleting this keeps the rest of the cache, which nakes the project creation faster.

@lpeabody
Copy link

This was very helpful, thank you.

@JCarlosR
Copy link

Thank you very much. I see this works with absolute paths in Windows too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment