Repository navigation
Kirby 6 support
The loader now works with Kirby 6 (tested with 6.0.0-beta.2). On Kirby 6 with debug enabled, the first plugin folder with only an index.js or index.css file stopped the whole site with "Passing the root inside the extends array has been deprecated" (plugin-extends-root). These anonymous plugins are now registered with the named root argument, the same way Kirby registers them from site/plugins. (96ade37)
Breaking changes
- Requires Kirby 4.3 or newer and PHP 8.1 or newer. The named
rootargument ofApp::plugin()exists since Kirby 4.3.0. For Kirby 3 and Kirby 4.0 to 4.2, keep using 2.x:composer require afbora/kirby-loader:^2.3. (5a1a86c) - Folders that start with
_are skipped, like insite/plugins. Before,_my-pluginin a root was loaded. Rename it if you still want to load it. (e02f8f7) - Relative roots are always resolved against the index root. Before, a root like
plugins(without a leading slash) was first looked up in the current working directory, so the result depended on where PHP was started (for example a CLI script or a cron job). Roots with a leading slash and absolute paths work as before. (2cbf2f0)
Fixes
- An
_folder with only anindex.jsorindex.cssfile stopped the site with "The plugin name must follow the format", because Kirby doesn't allow_in plugin names. Such folders are now skipped (see above). This happened on Kirby 4, 5 and 6. (e02f8f7) - A callback that returns
nullthrew aTypeErrorand stopped the site, for example the README exampleoption('custom.option.path')when that option isn't set. It is now skipped. (59d99bf) - An empty string as a root loaded the site's own
index.phpas a plugin and rendered the site a second time. Empty roots are now skipped. (59d99bf)
New
- A callback can return a list of roots:
fn () => ['/plugins/blog', '/plugins/shop']. (59d99bf) afbora.loader.rootsalso accepts a single root (a string or a callback) instead of an array. (f9e36da)
Changes
composer.jsonno longer has aversionfield, so the git tag is the only version source. A tag that didn't match the field kept 2.3.1 off Packagist (#7). (2b6efbe)composer.jsonhasextra.kirby.compatible: ^4.3 || ^5.0 || ^6.0and the keywordskirby4,kirby5andkirby6(waskirby3tokirby5).minimum-stabilityandprefer-stableare removed, because they only apply when the plugin itself is the root package. (5a1a86c, 83eacca)- Code cleanup: typed property,
instanceof Closureand/as path separator, like Kirby core. (f9e36da) - PHPUnit tests and a GitHub Actions workflow that runs them on Kirby 4.3.0, the latest 4.x, 5.x and 6.x, with PHP 8.1 to 8.5. (09cce50, 06bf0b5)
.gitattributeskeeps the tests and CI files out of the Composer package. (c0dafe7)- README: supported versions, how roots are resolved, skipped folders, and callbacks that return several roots, plus a cover image. (8cf59d0, 830124f)
Tested with
- The new test suite (12 tests) passes on Kirby 4.3.0 with PHP 8.1, Kirby 4.9.6 with PHP 8.4, Kirby 5.6.2 with PHP 8.2 and 8.4, and Kirby 6.0.0-beta.2 with PHP 8.3 and 8.5. With 2.3.2, 9 of the 12 tests fail on Kirby 5 and 6, and Kirby 6 also reports the deprecation.
- A Starterkit on Kirby 6.0.0-beta.2 and 5.6.2: a folder of plugins, a root that is a single plugin, a callback that returns a list, a missing root,
_and.folders, Windows-style absolute paths, and a duplicate plugin name, which throws the sameDuplicateExceptionas Kirby core. - The Panel loads the CSS and JS of an anonymous plugin from an extra root (
media/plugins/plugins/{name}.{hash}.css|js).
Full Changelog: 2.3.2...3.0.0