1

I'm trying to write my own Craft 3 TWIG filter / functions.

For this purpose I created a scaffolding using pluginfactory.io. I did a composer require and composer correctly symlinks the plugin to the Craft project's vendor directory. When I click "Plugins" in the CP it shows my plugin, but when I click "Install" I get the error:

Call to a member function getVersion() on null

caused in /var/www/html/vendor/craftcms/cms/src/services/Plugins.php on line 328 which is

$info = [
  'handle' => $handle,
  'version' => $plugin->getVersion(), // <== Line 328
  'schemaVersion' => $plugin->schemaVersion,
  'installDate' => Db::prepareDateForDb(new \DateTime()),
];

Why? I compared my composer.json with e.g. nystudio107/craft3-pathtools and it's almost identical and I definitely have a version defined in my composer.json.

Why is $plugin null?

Any suggestions?

  • Can you edit the question and share you main plugin class file (if it has one) as well as your plugin's composer.json? – Brad Bell Jul 31 '17 at 23:09
  • hey brad: see answer below, only idea: maybe craft should check if the file exists before not being able to initiate the plugin – Matthias Redl-Mann Aug 2 '17 at 15:24
1

Shame on me, but maybe still interesting to others who have this problem: I'm using vagrant and the path of my extension was NOT mounted to the vagrant box. That's all. So it simply could not find the files. Maybe a warning by craft would be nice, that it can not load the plugin files

Though I do not understand, why it found the composer.json to read the basic information, which showed up in the Plugins section of Craft...

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.