phpgitcomposer-phpsymfonysatis

What's the proper way to use SATIS with shared internal library


The problem:

I have Entities that are and will be the same for 2 projects written in Symfony. We got an idea to share them between projects. The first idea was to use git sub-module but everyone knows that it's not the most comfortable solution. So we put them in Satis as separate git repository.

In one project I would like to edit them in application directory src/AppBundle/Entity on the other they can be downloaded into vendor directory.

The question is how to setup composer so I can work with them not in vendor directory. How the commits will look like? Is git sub-module required for this?

I've already read about "type" : "path" for repository, I've checked composer installers. Is there any other solution than symlink which comes to my mind right now?

So to sum up.

How to work with shared library in one project from app directory and on the other on vendor directory?


Solution

  • This is the solution that worked for me.

    I've cloned internal library into project.

    In main project I've added this directory to .gitignore and in composer.json I've added following lines

    "repositories": [
            {
                "type": "path",
                "url": "internal-library",
                "options": {
                    "symlink": true
                }
            },
            {
                "type": "composer",
                "url": "http://our-satis"
            }
        ],
    

    In the other project I've added only satis repository(the entities will be changed only in one project and imported to the other).

    "repositories": [
                {
                    "type": "composer",
                    "url": "http://our-satis"
                }
            ],
    

    So now in development when I do composer update the library is symlinked to vendor directory. If I don't have this directory it will be get from satis. In production repository will be get from satis because my direc tory does not exist. I've had some issues with PSR loading but everything works as expected.

    I hope it will help someone having same issues as I had.