Skip to content

Instantly share code, notes, and snippets.

@pauldominik
Last active April 21, 2016 07:24
Show Gist options
  • Save pauldominik/65ae1034f6072faa40c4ffb64a1ffa6c to your computer and use it in GitHub Desktop.
Save pauldominik/65ae1034f6072faa40c4ffb64a1ffa6c to your computer and use it in GitHub Desktop.
Easy Package Development for Laravel 5

The Scenario

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.

The Benefits

  • Main project is clean of any code /files that concern only the package development
  • Pushing to packagist is not required

Steps

  1. 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
  2. Branch off your main project. I named mine p-deploy (p for package).
  3. 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.

Again, the Benefits

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment