Local workflow for private Composer packages

A simple symlink between the composer package and your project allows you to keep your core code all in one place.

Categories: Development

I work on two rather large projects that follow two specific life cycles. I want to show you how easy it is to use and setup private Composer packages for use in Laravel. This does not need to be a private package and will work just the same with a public package that you might be maintaining.

My main project is an evergreen project. Its features are tested, optimized and then rolled out to the other sites. Rather than leaving all of my site-specific configs, services, and other required logic in each app I use a private package with Composer. This allows me to manage my projects independently while maintaining a sane workflow with the composer package. It’s technically a third project.

Assuming that you know how to make a private package for Composer let’s skip right to the meat of the idea.

Locally I have a setup like this.

- /App 1
    - Vendor
-  /App 2
    - Vendor
- /Composer Package

A simple symlink between the composer package and your project allows you to keep your core code all in one place. Make sure to run composer install before you create the symlink.

ln -s ~/Sites/composer-package/src ~/Sites/work/app 1/vendor/packagename/core

You have the choice to install that private Composer package as normal in App 2 or share it as well by using a symlink.

From here, you can now share the same code with two projects while still maintaining Composer versioning and the version control of your code.

This process is really helpful when working on new code inside of your composer package. Simply create a new branch and your apps will automatically be switched over. There is no need to run any composer commands.


Adam Patterson

Adam Patterson

User Interface Designer & Developer with a background in UX. I have spent 5 years as a professionally certified bicycle mechanic and ride year-round.

I am a husband and father of two, I enjoy photography, music, movies, coffee, and good food.

You can find me on Twitter, Instagram, and YouTube!