Closed vhontar closed 7 years ago
Can you find the error in your logs (storage/logs/) and paste in the full stack trace?
Hi, sorry for my late response. Here it is:
2017-10-02 01:05:27 [172.18.0.1][1][8pnp3mk90eid8nqficbrshld03][error][Error] Error: Call to a member function getVersion() on null in /var/www/public_html/vendor/craftcms/cms/src/services/Plugins.php:332
Stack trace:
#0 /var/www/public_html/vendor/craftcms/cms/src/controllers/PluginsController.php(49): craft\services\Plugins->installPlugin('paymen...')
#1 [internal function]: craft\controllers\PluginsController->actionInstallPlugin()
#2 /var/www/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /var/www/public_html/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#4 /var/www/public_html/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('install-plugin', Array)
#5 /var/www/public_html/vendor/craftcms/cms/src/web/Application.php(238): yii\base\Module->runAction('plugins/install...', Array)
#6 /var/www/public_html/vendor/craftcms/cms/src/web/Application.php(363): craft\web\Application->runAction('plugins/install...', Array)
#7 /var/www/public_html/vendor/craftcms/cms/src/web/Application.php(198): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 /var/www/public_html/vendor/yiisoft/yii2/base/Application.php(380): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /var/www/public_html/web/index.php(21): yii\base\Application->run()
#10 {main}
2017-10-02 01:05:27 [172.18.0.1][1][8pnp3mk90eid8nqficbrshld03][info][application] $_POST = [
'pluginHandle' => 'payment'
'CRAFT_CSRF_TOKEN' => '••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••'
'action' => 'plugins/install-plugin'
]
$_COOKIE = [
'CraftSessionId' => '8pnp3mk90eid8nqficbrshld03'
'1031b8c41dfff97a311a7ac99863bdc5_username' => '7fb293f43046ae44f4217ba596408b634b7911432d69bf41df6309c5a8a6276ca:2:{i:0;s:41:\"1031b8c41dfff97a311a7ac99863bdc5_username\";i:1;s:4:\"vlad\";}'
'CRAFT_CSRF_TOKEN' => '•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••'
'1031b8c41dfff97a311a7ac99863bdc5_identity' => 'b156b6ffcc89569ff395fcce0408a6a4a80e522c4d95d816321212a1744c97e0a:2:{i:0;s:41:\"1031b8c41dfff97a311a7ac99863bdc5_identity\";i:1;s:272:\"[\"1\",\"[\\\"_qCsCYl2IaTYPL-SgI1-SCUlOrA4T9NeC6AodPDjdT1A8ogaFUi0JJCQkiDlJk_HoS2dtkqtFRuYzzPwdvl3MG8qljYtQ3WLtoYU\\\",\\\"d8a604da-d86a-4070-ba5c-3c727bf147da\\\",\\\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36\\\"]\",1209600]\";}'
]
$_SESSION = [
'bd62416aa8538ede709019a5e113eea5__flash' => []
'1031b8c41dfff97a311a7ac99863bdc5__id' => '1'
'1031b8c41dfff97a311a7ac99863bdc5__expire' => 1506935127
]
$_SERVER = [
'USER' => 'km'
'HOME' => '/home/km'
'HTTP_COOKIE' => 'CraftSessionId=8pnp3mk90eid8nqficbrshld03; 1031b8c41dfff97a311a7ac99863bdc5_username=7fb293f43046ae44f4217ba596408b634b7911432d69bf41df6309c5a8a6276ca%3A2%3A%7Bi%3A0%3Bs%3A41%3A%221031b8c41dfff97a311a7ac99863bdc5_username%22%3Bi%3A1%3Bs%3A4%3A%22vlad%22%3B%7D; CRAFT_CSRF_TOKEN=b4e3e6c90210c0ec0c41f16fdab26f9997d53271a1c68947c34778d4660fb3f5a%3A2%3A%7Bi%3A0%3Bs%3A16%3A%22CRAFT_CSRF_TOKEN%22%3Bi%3A1%3Bs%3A208%3A%22sF4gtbRROFXhuJDPKAGf57UxdE0sfOgYqjlbrDPH%7C6428fb15f685ec10d87bf2d203fe306dff2d5597575f7d9634349d8f6f4de147sF4gtbRROFXhuJDPKAGf57UxdE0sfOgYqjlbrDPH%7C1%7C%242y%2413%24GPbS4cebXuCT0Wf6X4KKo.9p23FU1UeAl4OB8m7pktt4hHF28S.si%22%3B%7D; 1031b8c41dfff97a311a7ac99863bdc5_identity=b156b6ffcc89569ff395fcce0408a6a4a80e522c4d95d816321212a1744c97e0a%3A2%3A%7Bi%3A0%3Bs%3A41%3A%221031b8c41dfff97a311a7ac99863bdc5_identity%22%3Bi%3A1%3Bs%3A272%3A%22%5B%221%22%2C%22%5B%5C%22_qCsCYl2IaTYPL-SgI1-SCUlOrA4T9NeC6AodPDjdT1A8ogaFUi0JJCQkiDlJk_HoS2dtkqtFRuYzzPwdvl3MG8qljYtQ3WLtoYU%5C%22%2C%5C%22d8a604da-d86a-4070-ba5c-3c727bf147da%5C%22%2C%5C%22Mozilla%2F5.0+%28X11%3B+Linux+x86_64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F60.0.3112.90+Safari%2F537.36%5C%22%5D%22%2C1209600%5D%22%3B%7D'
'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,uk;q=0.2,de;q=0.2'
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, br'
'HTTP_REFERER' => 'http://127.0.0.1:32769/admin/settings/plugins'
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
'HTTP_CONTENT_TYPE' => 'application/x-www-form-urlencoded'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1'
'HTTP_ORIGIN' => 'http://127.0.0.1:32769'
'HTTP_CACHE_CONTROL' => 'max-age=0'
'HTTP_CONTENT_LENGTH' => '637'
'HTTP_CONNECTION' => 'keep-alive'
'HTTP_HOST' => '127.0.0.1:32769'
'SCRIPT_FILENAME' => '/var/www/public_html/web/index.php'
'REDIRECT_STATUS' => '200'
'SERVER_NAME' => 'craft.dev'
'SERVER_PORT' => '80'
'SERVER_ADDR' => '172.18.0.4'
'REMOTE_PORT' => '36234'
'REMOTE_ADDR' => '172.18.0.1'
'SERVER_SOFTWARE' => 'nginx/1.13.3'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'REQUEST_SCHEME' => 'http'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'DOCUMENT_ROOT' => '/var/www/public_html/web'
'DOCUMENT_URI' => '/index.php'
'REQUEST_URI' => '/admin/settings/plugins'
'SCRIPT_NAME' => '/index.php'
'CONTENT_LENGTH' => '637'
'CONTENT_TYPE' => 'application/x-www-form-urlencoded'
'REQUEST_METHOD' => 'POST'
'QUERY_STRING' => ''
'FCGI_ROLE' => 'RESPONDER'
'PHP_SELF' => '/index.php'
'REQUEST_TIME_FLOAT' => 1506931527.6034
'REQUEST_TIME' => 1506931527
'DB_DRIVER' => 'mysql'
'DB_SERVER' => 'db'
'DB_USER' => 'craft_dev'
'DB_PASSWORD' => '••••••••••••••••'
'DB_DATABASE' => 'craft_dev'
'DB_SCHEMA' => 'public'
'DB_TABLE_PREFIX' => ''
]
Make sure your primary plugin class extends craft\base\Plugin
.
I've tried it, but it didn't help. I am installing this plugin using path in craft 3 composer.json. (Maybe it can help somehow to understand) Here is my code:
<?php
namespace company\me;
use Craft;
use craft\events\RegisterUrlRulesEvent;
use craft\web\UrlManager;
use yii\base\Event;
use company\me\models\Settings;
class Plugin extends craft\base\Plugin
{
public $hasCpSection = true;
public function init()
{
parent::init();
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function(RegisterUrlRulesEvent $event) {
$event->rules['test'] = 'test/sum/bar';
});
}
/**
* @return Settings
*/
protected function createSettingsModel()
{
return new Settings();
}
/**
* @return string
*/
protected function settingsHtml()
{
return Craft::$app->getView()->renderTemplate('test/settings', [
'settings' => $this->getSettings()
]);
}
}
composer.json
{
"name": "company/test",
"description": "System Test",
"version": "1.0.15",
"type": "craft-plugin",
"minimum-stability": "dev",
"require": {
"craftcms/cms": "~3.0.0-beta.28"
},
"autoload": {
"psr-4": {
"company\\my\\": "src/"
}
},
"support": {
"email": "you@example.com"
},
"extra": {
"handle": "test",
"name": "Test System",
"developer": "me",
"developerUrl": "https://me.org",
"version": "1.0.15",
"schemeVersion": "1.0.15",
"hasCpSettings": true,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/wbrowar/craft-3-adminbar/master/CHANGELOG.md",
"components": {
},
"class": "company\\me\\Plugin"
}
}
Settings.php
<?php
namespace company\me\models;
use craft\base\Model;
class Settings extends Model
{
public $sum = 100;
public $bar = 'defaultBarValue';
public function rules()
{
return [
['sum', 'integer'],
[['sum', 'bar'], 'required'],
// ...
];
}
}
Sorry should be \craft\base\Plugin
. You need the slash at the beginning because your plugin is not in the root namespace (as it shouldn’t).
Thank you for your response, but i have the same error
I have successfully installed contact-form plugin from Pixel & Tonic. Without any error.
I have updated craft 3 cms to beta 29. But i have the same error.
@vhontar try generating your plugin scaffolding here: https://pluginfactory.io/
Make sure you set the API version to 3.x
After logging creating plugin by Plugins service. I understood, that composer create symbolic link to my local plugin, despite i ran my project in docker, naturally that docker doesn't know where symbolic link points. I resolved this problem adding one param to composer.json
"repositories": [
{
"type": "path",
"url": "/home/****/****/php-projects/plugins/test",
"options": {
"symlink": false
}
}
]
Thank you for your help.
@vhontar I was interested in your case, and should have thought of this. It was the nature of the error that led me off, though this may be the actual response when Craft has installed the plugin previously, but now has no source to run it.
It's probably not Docker that causes the problem, but how you are getting the plugin in there.
Unless you are developing directly within the Docker instance, you have to consider how a symbolic link will be (or not be) compatible between your development machine and the runtime.
There's further complication possible in debugging and so forth, that under Craft 3, the code that executes will be under /vendor, while you should be editing somewhere else. Thus unless you want to rerun composer for every edit...problems.
What I do is keep the link, but tell my code->released Docker transfer via rsync to copy_symlinks. This is particularly easy to do with Ansible, but you can do it in any arrangement.
I develop in a Linux vm. There I arrange the IDE (PhpSto;rm) to map and write to the /vendor/mysignature area where the plugin runs from, via 'instant' sftp.
Similarly, I use xdebug server mapping of this IDE to connect the source with the /vendor /mysignature area.
This arrangement gets me very rapid loading when the vm starts, and then instant editing along with debugger. Some variation may help you. I don't develop directly in Docker, but on the same version of Ubuntu in the vm (Vagrant).
May give you some thoughts for your own situation.
@narration-sd thank you for your response) it's a good solution for me)
@vhontar glad to hear it...and please note my slight update correction: I use sftp (the one in PhpStorm) to instantly update from edits.
You can set PhpStorm to sftp on a ctrl-S -- see Deployment>Options>Upload changed files... and select Explicit Save from the dropdown.
If you are using that...best fortune in any case, of course...
Description
Hi, i am using craft3 beta 28. I am trying to create my own plugin using your docs. I created folder, added composer.json to root, next step i created src folder with Plugin.php in it, and added just one method init(). That's all. Then in the composer in craft project i added repository to this plugin and installed it to the project. Then i opened settings->plugins, then i clicked in install button and got this error.
I had successfully installed https://github.com/craftcms/contact-form plugin to the project without error before i tried to install mine plugin. I run craft in docker containers. Maybe it's somehow cause this error, but i had successfully installed contact-form plugin.
Maybe i something missed. But i used your docs, just
Intro to Plugin Dev
.i hope you help to find out what i did wrong or what i should do to make plugin works. Thank you for your help.
Steps to reproduce
Intro to Plugin Dev
Additional info