scottharwell / GoogleCharts

CakePHP Plugin for Google Charts Javascript API
26 stars 30 forks source link

Fatal error: Class 'GoogleChart' not found in /app/Controller/(...) #4

Closed kamilosinski closed 11 years ago

kamilosinski commented 11 years ago

Hey,

I have basic problem I think:

When I try to use this plugin i get: Fatal error: Class 'GoogleChart' not found in /app/Controller/(...)

I installed the plugin in the plugins direcotry. Also added:

App::uses('AppController', 'Controller', 'GoogleChart', 'GoogleChart.Lib');

Controller Code:

class ReportsController extends AppController {

public $helpers = array('GoogleChart.GoogleChart');

public function index() {

    $Clients = $this->Report->Client->find(
        'all',
        array(
            'order' => array('Client.date' => 'ASC'),
            'limit' => 10,
            'fields' => array(
                'Client.date',
                'Client.email'
             )
       )

);

$chart = new GoogleChart();

(...)

Am I doing something wrong?

scottharwell commented 11 years ago

You're incorrectly using App::uses. It only loads one file at a time. It should be like:

App::uses('AppController', 'Controller');
App::uses('GoogleChart', 'GoogleChart.Lib');

However, It sounds like you haven't loaded the plugin via your bootstrap file. Have you done that? There is an example in that file on how to load plugins.

kamilosinski commented 11 years ago

It works!

Thanks a lot!