I've created my first Craft3 plugin and installed it locally via a composer.json path. After doing the composer require
, the plugin showed up as installed (with a green dot) under Admin->Settings->Plugin.
However, the plugin has the following code:
$plugins=Craft::$app->plugins->getAllPluginInfo();
error_log('We have version '.$this->getVersion().' and handle '.$this->getHandle());
$plugin=Craft::$app->plugins->getPlugin($this->getHandle());
if ($plugin==null) {
error_log('Could not find self');
} else {
error_log('Fond self with version: '.$plugin->getVersion());
}
/* @var PluginInterface $plugin */
foreach ($plugins as $plugin) {
error_log(json_encode($plugin));
}
calling any page and then checking storage/logs/phperrors.log
shows:
22-Jan-2019 13:18:52 Europe/London] We have version 1.0.0 and handle craft-project-name
[22-Jan-2019 13:18:52 Europe/London] Could not find self
...
[22-Jan-2019 13:18:52 Europe/London] {
"developer":"myname",
"developerUrl":"https:\/\/www.example.com",
"description":"Example plugin",
"documentationUrl":"https:\/\/www.example.com",
"class":"rbairwell\\craftprojectname\\Plugin",
"basePath":"\/Applications\/Dev\/craftcms\/craft-project-name\/src",
"aliases":{"@rbairwell\/craftprojectname":"\/Applications\/Dev\/craftcms\/vendor\/rbairwell\/craft-project-name\/src"},
"name":"Craft Project Name",
"version":"1.0.0",
"sourceLanguage":"en-US",
"hasCpSection":false,
"packageName":"rbairwell\/craft-project-name",
"isInstalled":true,
"isEnabled":false,
"moduleId":"craft-project-name",
"edition":"standard",
"hasMultipleEditions":false,
"hasCpSettings":false,
"licenseKey":null,
"licenseKeyStatus":"unknown",
"licensedEdition":null,
"licenseIssues":[],
"isTrial":false,
"upgradeAvailable":false}
...
Why is the plugin unable to find itself using getPlugin
even though it's confirm it's handle name and why, in the list of plugins does it come up isEnabled: false
even though the admin front end shows it as installed+enabled and obviously the plugin is functioning?