0
votes

When trying to include the JPGRAPH library in a Zend Studio project, I got the error

Fatal error: Class 'Graph' not found in C:\Program Files\Zend\Apache2\htdocs\NewStokV4\application\controllers\StatsController.php on line 49

when executing my code.

I tried to follow, unsuccessfully, some tutorials on the net, but none were complete nor clear to me. (I'm new in Zend framework development.)

this is what i get when trying include... or require...

Warning: require_once(vendors/jpgraph-3.5.0b1/src/jpgraph.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files\Zend\Apache2\htdocs\NewStokV4\application\controllers\StatsController.php on line 15

Fatal error: require_once() [function.require]: Failed opening required 'vendors/jpgraph-3.5.0b1/src/jpgraph.php' (include_path='C:\Program Files\Zend \Apache2\htdocs\NewStokV4\vendors\Oft_Framework-G1R1C0/vendors/minify-2.1.5/min/lib;C:\Program Files\Zend\Apache2\htdocs\NewStokV4\vendors\Oft_Framework-G1R1C0/vendors/htmlpurifier-4.4.0/library;C:\Program Files\Zend\Apache2\htdocs\NewStokV4\vendors\ZendFramework-1.10.7\library;C:\Program Files\Zend\Apache2\htdocs\NewStokV4\vendors\Oft_Framework-G1R1C0\library;C:\Program Files\Zend\Apache2\htdocs\NewStokV4/library;C:\Program Files\Zend\Apache2\htdocs\NewStokV4\vendors\ZendFramework-1.10.7\extras\library') in C:\Program Files\Zend\Apache2\htdocs\NewStokV4\application\controllers\StatsController.php on line 15

1
Where is the JPGRAPH libary located and how do you include it?simplyray
well i have the folder containing jpgraph classes and stuff, & the inclusion is what s causing me the problème, i tried including it in PHP include path, by specifying the jpgraph folder path, but it didn t work!osm2

1 Answers

0
votes

Regarding your comment:

Solution A (a bit dirty)

Put the whole JPGRAPH library inside \library\jpgraph folder an include it inside your controller via:

require_once(APPLICATION_PATH . '/../library/jpgraph/jpgraph.php');

Solution B (better)

Check if jpgrah uses namespaces. if yes you might want try to load it with the build in autoloader function of zend. Put the whole JPGRAPH library inside \library\JPGraph folder.

Usage: just add autoloaderNamespaces[] = "<jpgraph_namespace>" to your application.ini where <jpgraph_namespace> is the namespace of jpgraph.

So assuming the namespace is JPGraph:

application.ini:

[...]

includePaths.library = APPLICATION_PATH "/../library"

[...]

autoloaderNamespaces[] = "JPGraph"

in your controller:

[...]

$JPGraph = new JPGraph();

[...]