Class' highcharts \ Highcharts'找不到[yii2手动安装扩展程序]

时间:2016-08-22 07:30:10

标签: php yii2 yii2-basic-app

所以我是Yii2的新手。我试图在我的应用上安装第一个扩展程序(我计划托管webapp)。我尝试过与作曲家合作,但它没有用。

我将扩展文件夹放在此处:vendor/highcharts/src/

这是我在 extension.php中写的:

'highcharts' => array(
'name' => 'highcharts',
'version' => '4',
'alias' => array(
      '@highcharts' => $vendorDir . 'highcharts',
    ),
),

autoload_psr4.php中:

'highcharts\\' => array($vendorDir . '/highcharts/src'),

Di view.php:

<?php
use highcharts\Highcharts;
echo Highcharts::widget([
   'options' => [
     'title' => ['text' => 'Fruit Consumption'],
   'xAxis' => [
      'categories' => ['Apples', 'Bananas', 'Oranges']
   ],
   'yAxis' => [
      'title' => ['text' => 'Fruit eaten']
   ],
   'series' => [
      ['name' => 'Jane', 'data' => [1, 0, 4]],
      ['name' => 'John', 'data' => [5, 7, 3]]
   ]
   ]
]) ;

错误是说:

  

Class&#39; highcharts \ Highcharts&#39;找不到

我已尝试编辑use部分。但仍然没有结果。那么我错过了什么?

1 个答案:

答案 0 :(得分:0)

extension.php

中的

if (isset($bar)):
   if (isset($foo)) {
     echo "Both are set.";
   };
elseif (...):

并在 autoload_psr4.php

'miloschuman/yii2-highcharts-widget' => 
  array (
    'name' => 'miloschuman/yii2-highcharts-widget',
    'version' => '5.0.2.0',
    'alias' => 
    array (
      '@miloschuman/highcharts' => $vendorDir . '/miloschuman/yii2-highcharts-widget/src',
    ),
  ),

但是为什么你没有作曲家工作?

您可以添加

'miloschuman\\highcharts\\' => array($vendorDir . '/miloschuman/yii2-highcharts-widget/src'),

到composer.json

并运行

"miloschuman/yii2-highcharts-widget": "^5.0"