- You are working on a Laravel 5.2 project
- You are adding a feature that you want to reuse with other Laravel 5 projects,
- For this one, lets assume we are doing https://github.com/pauldominik/deploy
This is when package development comes in. I'm listing good tips on how you can do your dev workflow. So let me start with the gains.
- Main project is clean of any code /files that concern only the package development
- Pushing to packagist is not required
- Make your package directory one folder above your laravel projects so you can easily do relative referencing. e.g. I created a packagist folder and do usual stuff, like packagist/pauldominik/deploy
- Branch off your main project. I named mine p-deploy (p for package).
- In your main project's composer.json, we will use the repositories property that allows you to pull your package from an arbitrary loc instead of packagist. In my Windows environment, it allows relative file paths. So here's mine below.
"repositories": [
{
"type": "vcs",
"url": "../packagist/pauldominik/deploy/"
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.29",
"pauldominik/deploy": "dev-master"
},
Notice that I still added "pauldominik/deploy": "dev-master" as a requirement. If you need to use a specific branch, e.g. fixes branch on your package, then you have to use "dev-fixes" as the version.
Pretty much that's it. Since you have the package under development in a separate folder above your project, no need to worry about accidentally including it in your main repo. Also, when you publish assets or config, they are all in your p-nameOfPackage branch.