bnomei / kirby3-qrcode

Generate QRCodes easily.
https://forum.getkirby.com/t/plugin-qr-code-field-and-page-method/6798
MIT License
12 stars 3 forks source link

Class compatibility with git submodules #18

Closed dgsiegel closed 2 years ago

dgsiegel commented 2 years ago

I've added this plugin via a git submodule. When trying to change the background or foreground colors with:

'foregroundColor' => new \Endroid\QrCode\Color\Color(0, 0, 0),

I get the following exception:

[Tue Feb 15 14:06:02 2022] PHP Fatal error:  Uncaught Error: Class "Endroid\QrCode\Color\Color" not found in site/config/config.php:67
Stack trace:
#0 kirby/src/Filesystem/F.php(410): include()
#1 kirby/src/Filesystem/F.php(387): Kirby\Filesystem\F::loadIsolated()
#2 kirby/src/Cms/App.php(990): Kirby\Filesystem\F::load()
#3 src/Cms/App.php(95): Kirby\Cms\App->optionsFromConfig()
#4 cms/index.php(5): Kirby\Cms\App->__construct()
#5 kirby/router.php(14): require('...')
#6 {main}
  thrown in site/config/config.php on line 67
bnomei commented 2 years ago

config is loaded before the plugins. stuff like that only works with composer. if you want to do that with gitsubmodules you have to include the autoloader from the qrcode plugin at the header of your config file.

https://github.com/bnomei/kirby3-qrcode/blob/1d77b953c9315dd8d22e40225551785d4118796e/index.php#L3

site/config/config.php (untested)

@include_once __DIR__ . '/../site/plugins/kirby3-qrcode/vendor/autoload.php';

return [
    // config stuff
];
dgsiegel commented 2 years ago

You had it almost, this is the correct path:

@include_once __DIR__ . '/../plugins/kirby3-qrcode/vendor/autoload.php';