Composer: Path Repositories

When working on a php package it is inconvenient to push the package to github (or other repository) and then wait for the package to update using composer update.  For package development, composer has such feature as path repositories.  Let’s imagine we have a two folders on the same level:  my-app and  package.   my-app is an app — a test bed for our package and package is a php package we are developing:

my-app

package

In my-app‘s composer.json we can include:

"repositories": [ 
  {
    "type": "path",
    "url": "./../package"
  }
]

Now you can simply go to the require block of the composer.json file of the application (my-app) and require your package.

"require":
  {
    //other required packages
    "apr/package": "master@dev"
  }

After that you can do composer update and composer will take care of the package and any dependencies it needs.  Then you can use this package like any other package installed through composer.

Share this article

Posted

in

,

by

Tags: