首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在CakePHP 2.xShell中调用插件?

如何在CakePHP 2.xShell中调用插件?
EN

Stack Overflow用户
提问于 2018-04-11 10:07:39
回答 1查看 98关注 0票数 1

我试图在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]

这是我的密码:

代码语言:javascript
复制
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');
  }

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-26 15:15:22

这是我的解决方案,它就像一种魅力:

代码语言:javascript
复制
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');
  }

}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49772231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档