2

Environment:Amazon EC2. Ubuntu x64. (GD library installed) I'm recently using phpChart for graph and report in laravel framework. I'm stuck at the beginning stage.

Here's what I've done.

  • 1.Unzip the contents in phpChart_Lite to /var/www/app/libraries/phpChart.
  • 2.Edit composer.json and add :

    "autoload": {
        "classmap": [
            ...
            "app/libraries"
        ]
    },
    
  • 3.run:composer dump-autoload

  • 4.modify conf.php in phpChart_Lite

    define('SCRIPTPATH',app_path().'/libraries/phpChart_Lite/');
    

Here's my test page code:

<?php
require_once(app_path()."/libraries/phpChart_Lite/conf.php");
$pc = new C_PhpChartX(array(array(11, 9, 5, 12, 14)),'basic_chart');
$pc->draw();
?>

ps.my app_path() is verified by "echo app_path()" and it is "/var/www/app".

Here's my error message:

Unknown: Failed opening required '/var/www/public//var/www/app/libraries/phpChart_Lite//conf.php' 
(include_path='/var/www/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/php:/usr/share/pear') 
4
  • I've set the permission 777 to /libraries and it's sub-directories. the path in the error message is definitely wrong:"/var/www/public//var/www/app/library". But my code is right. That's what bothers me most. Commented Aug 5, 2014 at 8:05
  • for more information. the error occurs on the file:/var/www/app/libraries/phpChart_Lite/server/cls_conf.php Commented Aug 5, 2014 at 8:20
  • 2
    I saw double slashes BEFORE conf.php in the error message. That would likely be the cause to Failed opening required". Unknown: Failed opening required '/var/www/public//var/www/app/libraries/phpChart_Lite//conf.php' Commented Aug 6, 2014 at 17:39
  • 1
    My guess is that the SCRIPTPATH is defined as "/var/www/app/libraries/phpChart_Lite/" modified by me. Thus, I consider this required path is written by phpchart as "WebsiteDirectory + SCRIPTPATH + conf.php". And my approach works. :D Commented Aug 8, 2014 at 3:22

1 Answer 1

4

After a lot of try-and-error, I somehow found the root cause, I guess. There are actually two main issue there. And here's my solution.

1.For my issue explained in the very first post. In the conf.php file in phpChart_Lite folder. The SCRIPTPATH is somehow prefixed with /var/www/public.

However, in my apache2.conf file states the directory to be /var/www. Regardless this prefix, I use a absolute path for SCRIPTPATH. The following modification works for me:

    define('SCRIPTPATH','../app/libraries/phpChart_Lite/');

The error was gone. But the second issue appears, that is the chart doesn't show up. Open the Chrome Developer Tool(press F12). On the 'Console' tab, I found error 404 for loading phpChar_Lite/js. One of the error messages as following:

   http://myip/app/libraries/phpChart_Lite/js/highlighter/styles/zenburn.css

As the design of Laravel, only public folder can be access by external request. So I got second issue. And here's my solution.(not a secured method)

2.Move the phpChart_Lite to public folder. Modify the code of test page:

    include_once(public_path()."/phpChart_Lite/conf.php");

Modify the conf.php in public/phpChart_Lite:

    define('SCRIPTPATH','phpChart_Lite/');

Everything's just fine now.

If you consider phpChart is too complicate to configure with, you might want to try pChart2.0. It doesn't require much setting. But the graph is terribly ugly.

I prefer phpChart for it's graph and function calls, though the setting is a little complicated and not laravel friendly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.