-1

Suppose a local svn repository Vendor has a subfolder tt containing multiple packages: core, core-analytics and so on. Each trunk folder for each package contains a composer.json file - naturally. This is for the core package;

{
  "name": "vendor/tt-core",
  ...
  "require": {
    "php": "^8.4"
    ...
  },
  "version": "dev-local",
  "autoload": {
    "psr-4": {
      "Tt\\Core\\": "./Classes/"
    }
  }
}

Other packages are similarly configured.

The dependent package's composer.json contains;


  "require": {
    "php": "^8.4",
    "vendor/tt-core": "@dev",
    "vendor/tt-core-analytics": "@dev"
    ...
  },
  "repositories": [
    {
      "type": "svn",
      "url": "https://svn:8443/svn/Vendor/tt",
      "package-path": "core/"
    }
  ],

This code snippet is widely shared in various SO questions. For some reason it seems not to work. What is the proper setup for this to work?

1 Answer 1

0

The answer is path not cvs. Currently, Composer has no way scanning for packages inside SVN repositories.

If you're an organizational junkie as I am, you probably have your files and folder organized in a particular manner, such as one described in the question.

Repository/
    ├── App/
    │    ├── core/
    │    │   └── composer.json
    │    └── core-analytics/
    │        └── composer.json
    └── Plugin
        ├── gateway/
        │   └── composer.json
        └── calendar/
            └── composer.json

For an any number of nested levels repository setup, have your repositories section in your root project's composer.json file configured like so.

"repositories": [
    {
      "type": "path",
      "url": "C:/Path/To/Your/Repository/*/*/*",
      "options": {
        "symlink": true
      }
    }
  ],

Repository in this example, is your working copy folder (where you work with your packages).

It uses global patterns in url. This will scan for packages three levels deep. If your packages go deeper, you'll need to extend /* per extra level as the glob /** doesn't work with composer.

When set to true, the symlink option simply installs a reference back to your package development folder - it copies no contents to the `vendor` folder - which is best for development. This way you can do small live development things such as setting break points inside your development files instead of having two separate copies. During deployment to a remote server, the option should definitely be set it to false to compel Composer to create a local copy in the root package for production.

If using svn, as I am, ensure you or your IDE updates your package whenever you commit changes to keep your filesystem copy updated. I find this a much better, simpler, convenient setup.

Leveling

Within your package hierarchy, if you have an inner-level package that depends on an outer-level package, you'll need to add an extra repository entry corresponding to the dependent package in your root composer to get Composer to find the dependent package. Example,

  "repositories": [
    {
      "type": "path",
      "url": "C:/Path/To/Your/Repository/*/*/*",
      "options": {
        "symlink": true
      }
    },
    {
      "type": "path",
      "url": "C:/Path/To/Your/Repository/*/*/*/*",
      "options": {
        "symlink": true
      }
    }
  ],

Am not sure what the behavior is with Composer specifically. perhaps this shall be improved in the future. For packages depending on each other within the same filesystem hierarchical level, the behavior works as expected without the need to add a repository path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.