Welcome Guest, Not a member yet? Register   Sign In
fail to use jpgraph in CI4
#1

Hello,
I need to use php jpgraph library, so i have put it in a folder (because of the large number of files) Jpgraph located in app\Libraries

so path to jpgraph class file is :
app\Libraries\Jpgraph\jpgraph.php

in a controller :

PHP Code:
use App\Libraries\Jpgraph\jpgraph;

    protected $jpgraph;

    public function initController(
        \CodeIgniter\HTTP\RequestInterface $request,
        \CodeIgniter\HTTP\ResponseInterface $response,
        \Psr\Log\LoggerInterface $logger
    
) {
        parent::initController($request$response$logger);
        $this->jpgraph = new Graph();
    

I got : Error, Class "App\Controllers\Graph" not found

if I change Graph to jpgraph
PHP Code:
$this->jpgraph = new jpgraph(); 

i got : ErrorException, Uncaught Error: Class "App\Libraries\Jpgraph\jpgraph" not found in [...]/app/Controllers

I migh have done something wrong, but what?
Reply
#2

In file app\Libraries\Jpgraph\jpgraph.php set namespace App\Libraries\Jpgraph\jpgraph? If not set probaly new \jpgraph()
Reply
#3

(This post was last modified: 08-21-2023, 07:18 PM by kenjis.)

It seems JpGraph is not autoloadable.
https://jpgraph.net/download/manuals/chu...e.example0

I recommend you require (adjust the file path):
PHP Code:
require_once ('jpgraph/jpgraph.php');
require_once (
'jpgraph/jpgraph_line.php'); 

and write like:
PHP Code:
$this->jpgraph = new \Graph(); 
Reply
#4

Ok, Thanks to you both, will try it.
Meanwhile have found this : https://packagist.org/packages/amenadiel/jpgraph
But for now, have to fix problems with twig use.
Have a nice day,
Eric
Reply
#5

Fatal error: Uncaught Error: Class "App\Libraries\Jpgraph\jpgraph\Text" not found in /home/[...]/traces/app/Libraries/Jpgraph/jpgraph.php
Sorry, I give up.
Reply
#6

JpGraph is not namespaced. So there is no "App\Libraries\Jpgraph\jpgraph\Text" class.
Reply
#7

(08-23-2023, 02:36 PM)kenjis Wrote: JpGraph is not namespaced. So there is no "App\Libraries\Jpgraph\jpgraph\Text" class.

Ok, thanks anyway
Reply




Theme © iAndrew 2016 - Forum software by © MyBB