Kirby may get composer support at some point in the future, but until then, here’s some code you can use to install kirby, toolkit, and the panel with composer.
(Using .gitmodules
works fine, but if you’re already using Composer, it’s much easier to just stick with it instead of working with git submodules.)
Custom Installation paths
Composer installs packages into /vendor
by default, but you can change that by using mnsami’s customer directory installer and doing a little tinkering.
To make it work, you’ll need to:
- Require mnsami’s customer directory installer. This handles custom installation paths.
- Explicitly define the repositories for
kirby
,toolkit
, andpanel
. (If Kirby had its owncomposer.json
file, you wouldn’t need to do this.) - Require each package
- Tell composer where to install each package
Your site’s composer.json
file:
{
"name": "mysite",
"require": {
"mnsami/composer-custom-directory-installer": "1.0.*",
"getkirby/kirby": "2.2.3",
"getkirby/toolkit": "2.2.3",
"getkirby/panel": "2.2.3"
},
"repositories": [
{
"type": "package",
"package": {
"name": "getkirby/kirby",
"version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/getkirby/kirby.git",
"reference": "2.2.3"
}
}
},
{
"type": "package",
"package": {
"name": "getkirby/toolkit",
"version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/getkirby/toolkit.git",
"reference": "2.2.3"
}
}
},
{
"type": "package",
"package": {
"name": "getkirby/panel",
"version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/getkirby/panel.git",
"reference": "2.2.3"
}
}
}
],
"extra": {
"installer-paths": {
"./kirby": ["getkirby/kirby"],
"./kirby/toolkit": ["getkirby/toolkit"],
"./panel": ["getkirby/panel"]
}
}
}
Then run
composer update
or
composer install
Installer Paths
You may install each package to whatever path you’d like. I often keep my site
directory outside of the web root, so I use something like the below for the extra
block. Just remember to use a custom site.php
or edit index.php
file to tell Kirby where the site
directory is (see $roots
).
Order is important here. You just want to make sure kirby/
is installed before toolkit/
is installed, since toolkit/
gets installed into kirby/
.
"extra": {
"installer-paths": {
"./public/kirby": ["getkirby/kirby"],
"./public/kirby/toolkit": ["getkirby/toolkit"],
"./public/panel": ["getkirby/panel"]
}
}
Git ignores
Don’t forget to add to your .gitignore
file(s):
# /.gitignore
...
/vendor
/kirby
/kirby/toolkit
/panel
Updating
When you’re ready to update to new Kirby releases, you’ll just change the version numbers in both your require
block and your repositories
block. Then run composer update
.
// update each package
"require": {
"getkirby/kirby": "2.2.4",
},
"repositories": {
{
"type": "package",
"package": {
"name": "getkirby/kirby",
"version": "2.2.4",
"source": {
"type": "git",
"url": "https://github.com/getkirby/kirby.git",
"reference": "2.2.4"
}
}
},
}
Alternatively, you can use Composer’s version constraints if you’d just like the latest version every time you run composer [install|update]
.