Kirby plugin development template

The plainkit and starterkit are pretty cool for starting out a project. However, what about plugins?

Let’s say I have a plugin that extends a very specific Kirby functionality. How would I test that? Sure, I can simply use the starterkit and put my plugin in site/plugins and then do whatever I want. But how to I track my plugin in Git? I simply add the plugin folder, correct, but what if someone decides to contribute? He has to install Kirby as well and somehow set it up the same way - content, blueprints, etc. That’s the biggest problem. Besides, if you only track the plugin in Git, you can’t track Kirby-related stuff like blueprints and content, which is problematic.

My suggestion is to have another template that uses Kirby’s functionality to change the site, content, etc. folders. This way, you can have the following directory structure:

/myplugin
  /kirby # Kirby installation that is ignored in Git
    /kirby
    /panel
    index.php
  /setup # Kirby configuration that is added to .gitattributes so it doesn't appear on Packagist
    /content
    /site
      /plugins
        /myplugin
          index.php # symlink to root index.php
          index.js # symlink
          index.css # symlink
  /src # plugin source
  .gitattributes
  .gitignore
  index.php # plugin PHP file
  index.js
  index.css
  package.json
  composer.json

With a setup like that, you can have Kirby completely out of Git while having a way to fiddle with it. Your configuration is in setup and is tracked, but ignored in .gitattributes so it doesn’t appear in the final tarball of Packagist. The only missing piece is how you can get Composer to install Kirby in the kirby folder and avoid its vendor shenanigans.

To contribute, you simply clone the repo, run composer install which should somehow install Kirby in kirby, and open the plugin in the browser by visiting http://localhost/myplugin/kirby.

Right now, I’m fiddling with the upcoming Editor plugin by @bastianallgeier and something like this would’ve helped out a lot.

i created quiet a few plugins and created another public repo with a kirby setup to try things and publish them later on. almost anyone could clone and start testing my plugins that way.

i usually tinker directly in the dev enviroment plugins folder and later copy their soure to the local git of the plugin.

maybe it helps you getting started without the need to squeeze kirby inside your plugins folder. but its a witty idea non the less.

1 Like