Question

EDIT: What I tried to achieve here can be done by the Yeoman project.


So I set up git+composer+satis on a private server, everything works fine, I'm really enthusiastic about it. Got to love them all.

I use git for projects, and for private packages, so now a basic workflow looks like this:

git clone git@myserver:the-project-name
composer install

This will clone the project repo, and install the required dependencies. Fantastic.

But I also want to be able to use some 'skeleton-repos' and just copy the contents of them into my project keeping the dependency information.

Take this example:

  • I create a git repo called: test-project, then I clone it locally.
  • I have another git repo, called fb-bootstrap, which is a skeleton for the facebook apps.
  • I also have another bootstrap skeleton git repo, which I also want to include: this will be an api/ folder for example. Let's call it: api-bootstrap
  • So I want to clone them as well, but of course I can't do that, because I already have a git repo in the same directory.
  • A possible solution: I use the following code, so I only get the files: 'git archive --format=tar --remote=git@myserver:the-bootstrap-repos HEAD | tar xf -'

This is fine, BUT it has a problem: I have different dependencies - Different composer.json files. - for the fb-bootstrap and the api-bootstrap repos, so I need to find a way to install all of them.

Note that I don't use composer for this, since I can't place anything in to the vendor/ folder other than autoloaded php classes, because the access is restricted to that folder.

Lifting that restriction won't solve the problem either, because if I add a dependency later, and I call composer update, I can lose the changes I made in the bootstrap folders.

Submodules and the only-copy-files hack above doesn't quite cut it because of the above mentioned reasons.

Summary:

I need a solution where I can include as many bootstrapping repos as I need to, and after I'm done with it, I must be able to install all the dependencies.

Like this:

  • git init a project repo,
  • git clone the project repo locally,
  • fetch a couple of bootstrap repos's content I need,
  • install the dependencies I declare for the project, and all the bootstrap repos's dependencies.

Is there a way to do this?

Also: If you think I approach this problem in a totally wrong way, please feel free to tell me. I'm adapting to new techniques anyway, I'm not scared about changes. :)

Any comment is appreciated.

Was it helpful?

Solution

I solved the problem more or less in the meantime.

First, I gave up on the idea of fully automatizing everything.

There are simply too much problem with combining the different bootstrapping repos; anything could happen, really.

One thing I wanted to still automate though, is merging the different dependencies of the bootstrap repos.

So after theese changes, I came up with a really simple script, which usage looks like this: ( Note that gitcopy is a script I use on my linux environment, which copies only the content of a repository. )

gitcopy git@server:bootstrap // Grabs the bootstrap.php file from a private repo.
php bootstrap.php fb-bootstrap api-bootstrap

The second command will create a new folder: 'bootstrap', and clones the repos into it. It then removes the .git folders, since I don't need version control there. It also bootstraps a base composer.json, and merges all the other composer.json files from the bootstaps in it. The bootstrap composer.json files are removed in the process, so I can just copy the bootstrap contents into my project's root folder, without prompts about overwriting other composer.json files.

So basically, it's just a nice little tool to grab everything I need, and after that I can deal with possible problems myself.

With this, I could use Yeoman generators, and still use my own bootstrap files, without worrying about conflicts.

The only thing I couldn't look into, is how to make this script a phar executable, so it could work like composer. Instead grabbing the bootstrap repo for the bootstrap.php, I could just say: bootstrap api webapp etc.

But that's for another day. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top