sylvainjule / kirby-embed

Embed field for Kirby 3 and 4.
74 stars 3 forks source link

autoloader issue when kirby-cms-path and kirby-plugin-path are set #2

Closed DenisLanz closed 4 years ago

DenisLanz commented 4 years ago

the plugin is not loading when kirby-cms-path and kirby-plugin-path are set in composer json, consider using the load helper: https://getkirby.com/docs/guide/plugins/plugin-setup-autoloader

sylvainjule commented 4 years ago

Apologies I'm not sure to understand what's expected, what would you want me to load with the load helper? Any hint welcome. 🙂

DenisLanz commented 4 years ago

I'm not a composer expert but I alter my folder structure by using kirby-cms-path and kirby-plugin-path in my composer file. If I install your plugin through composer - which is btw. confusing in your readme you write composer require sylvainjule/kirby-embed in the composer file you name it differntly composer require sylvainjule/embed and in the plugins folder it is named imagereadio - you should stick to something ;)

Anyway I get the following stacktrace, that tells me that something is odd while loading the rquired components for your plugin:

( ! ) Warning: require_once([…]/build/site/plugins/imageradio/vendor/autoload.php): failed to open stream: No such file or directory in […]/build/site/plugins/imageradio/index.php on line 3
Call Stack
#   Time    Memory  Function    Location
1   0.0004  425288  {main}( )   .../index.php:0
2   0.0019  541904  Kirby\Cms\App->__construct( )   .../index.php:6
3   0.0048  836736  Kirby\Cms\App->extensionsFromPlugins( ) .../App.php:119
4   0.0048  836736  Kirby\Cms\App->plugins( )   .../AppPlugins.php:546
5   0.0048  836736  Kirby\Cms\App->pluginsLoader( ) .../AppPlugins.php:689
6   0.0057  855280  include_once( '[…]/build/site/plugins/imageradio/index.php' )   .../AppPlugins.php:723
DenisLanz commented 4 years ago

Found the issue, as also written in the Kirby guideline (https://getkirby.com/docs/guide/plugins/plugin-setup-composer#support-for-plugin-installation-without-composer) you should not require the the autoloader but use include_once instead:

@include_once __DIR__ . '/vendor/autoload.php';

fixes the issue. Pretty simple. Now you just need to straighten out the naming.

sylvainjule commented 4 years ago

Thank you for taking the time to dig through it, I've made the change!

Also fixed the naming disparity, that's what happens when you use another of your field as a boilerplate and make stuff public too quickly :)

DenisLanz commented 4 years ago

I keep getting the old index.php and the old folder naming even though I cleared the composer cache and reset my project, even on another computer I keep getting the old version installing from scratch - I think you need to bump the version in order for composer to recognise the chance, or am I wrong?

Running composer install -vvv after composer clear-cache and removing the composer.lock shows that packagist is delivering the old version for version 1.0.0.

sylvainjule commented 4 years ago

Apologies, I didn't publish the release. Fixed!