我试图在CakePHP 2.xshell中使用一个插件(高级图表),但我没有工作。该插件在bootstrap.php (CakePlugin::load('Highcharts'))中加载,在应用程序中运行良好,但在shell中不工作。
我得到了以下错误:
Notice Error: Undefined property: MyTestShell::$Highcharts in [/Applications/MAMP/htdocs/myapp/vendors/cakephp/cakephp/lib/Cake/Console/Shell.php, line 513]
这是我的密码:
class MyTestShell extends AppShell {
public $components = array('Highcharts.Highcharts');
public function main() {
$this->out($this->makeChart());
}
public function makeChart() {
$mychart = $this->Highcharts->create('TestChart', 'column');
}
}发布于 2018-04-26 15:15:22
这是我的解决方案,它就像一种魅力:
App::uses('Controller', 'Controller');
App::uses('ComponentCollection', 'Controller');
App::uses('HighchartsComponent', 'Highcharts.Controller/Component');
class MyTestShell extends AppShell {
public function main() {
$Collection = new ComponentCollection();
$this->Highcharts = new HighchartsComponent($Collection);
$this->out($this->makeChart());
}
public function makeChart() {
$mychart = $this->Highcharts->create('TestChart', 'column');
}
}https://stackoverflow.com/questions/49772231
复制相似问题