-2

If a particular component of an application is decoupled enough from the parent that it can be used by other applications, how would I go about making that component into it's own composer package yet still maintain it in the scope of the parent application?

As an example, I'd like to achieve what Laravel did with it's database component: https://github.com/illuminate/database

Since it says READ ONLY, I'm under the impression that that "subtree" is still maintained from the parent Laravel/framework git repository yet retain the characteristics of a regular git repo in order for it to be distributed as a Composer package.

Is my impression accurate? How do I achieve this sorcery?

Thanks in advance.

OMR
  • 11,736
  • 5
  • 20
  • 35
Cesar Vega
  • 13
  • 1

1 Answers1

0

This is done by using git subtree splits, as explained in GitHub help:

$ git filter-branch --prune-empty --subdirectory-filter \
 YOUR_FOLDER_NAME master
# Filter the master branch to your directory and remove empty commits
# Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
# Ref 'refs/heads/master' was rewritten

Now the YOUR_FOLDER_NAME folder has become the root of your project and you can push this to another remote (another repository). That other repository now only contains YOUR_FOLDER_NAME and you can create a package for this.

Wouter J
  • 41,455
  • 15
  • 107
  • 112