0

I am working on several projects but each one connects to a REST web service.

I've developed the first one using Laravel, and developed a few classes really useful to communicate with the web services.

I would like to start the second one, and of course, reuse the classes developed for the REST connection.

My problem is, my company wants me to use several git directories for the projects, and each one should be uploaded to a different springloops project. Springloops is a bit like github, you can upload your code using git.

How would you proceed to avoid copy/paste and use the same laravel code but in different projects (and I guess, in different locations)?

I'm not sure I'm really clear, but don't hesitate to ask me for more information if you need to.

Thanks.

Vico
  • 1,696
  • 1
  • 24
  • 57

1 Answers1

1

How about creating your own Composer package and store it in a separate (private) Git repo? As far as Composer is concerned it's just like any other package, you may want to check out this section of the docs:

Using private repositories

Exactly the same solution allows you to work with your private repositories at GitHub and BitBucket:

{
    "require": {
        "vendor/my-private-repo": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "git@bitbucket.org:vendor/my-private-repo.git"
        }
    ]
}

The only requirement is the installation of SSH keys for a git client.

Erik Johansson
  • 1,646
  • 1
  • 14
  • 19
  • I don't know composer very well, for what I understand, composer allows you deal with packages, dependencies etc. I've just updated my whole project by doing a "php composer.phar update". If a create my own composer package, does that mean that each time this package is updated, all the other repositories will have to run "php composer.phar update"? Cannot it be done on each git pull? – Vico Mar 17 '15 at 06:27
  • It depends on your setup, but say you don't require a version but a branch (like in the example above): Since the actual package contents aren't in version control you wouldn't need to update the repos that rely on it in any way, just the working copies. This is something you just have to do periodically if you are working with a Composer project. If your projects aren't actually using Composer already though maybe you shouldn't shoehorn it in for one package. – Erik Johansson Mar 17 '15 at 13:04
  • Thank you for your help, I will give it a try, being able to split our code on different servers being absolutely mandatory. – Vico Mar 17 '15 at 23:17