I was about to get crazy because my Kirby Komment plugin wasn't working when installed via zip file. The solution? One line…
Sometimes I don't trust my own mind. My Kirby Plugin "Komments" is working smoothly on my site. I installed it using composer. Everything was fine.
But then I got an e-mail. Somebody installed my plugin and comments couldn't be saved. Even worse: even pages couldn't be saved!
The error message: A file within one of the dependencies wasn't found. I saw the relative path in the error message and thought that might cause the error. It wasn't.
I have a local install of the Kirby Starterkit to test things beside unit tests and to reproduce errors like this one. So I copied the local dev version of my plugin over to the starterkit and everything worked.
I updated the files on github. I downloaded the zip file. Installed it. It didn't work.
I played around with the composer setup and the autoloads. But nothing seems to work. So something must be happening during the creation of that zip file.
So I opened the terminal and ran a diff on my developer version and the zip file version:
diff -rq kirby/komments kirby-test/starterkit-master/site/plugins/komments
And there it was:
Only in kirby/komments/vendor/indieweb/mention-client: src
The mentionclient used for sending webmentions has its php files located in the its own src folder. That folder existed locally in my dev version and it could also be found in the github repo. I thought about that for a while and then…
I the tutorial for a Monolithic Plugin Setup there is this one file:
.gitattributes. Which causes to exclude certain folders and files from being part of the final package of the plugin. You need those files for development but not for production. And there was this one line:
So I could have skipped all that playing around with autoload. The solution was to remove that one line. After that all the files were included in the zip folder and everything worked. Phew…