Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Lavacharts in CodeIgniter ? #14

Closed
matthieubrunet opened this issue Dec 22, 2014 · 5 comments
Closed

How to use Lavacharts in CodeIgniter ? #14

matthieubrunet opened this issue Dec 22, 2014 · 5 comments
Assignees

Comments

@matthieubrunet
Copy link

Hi,

I would like to use Lavacharts as a CodeIgniter helper. I put the src/Khill/Lavachart drectory in my helpers directory and created a lavacharts_helper.php file :

require_once APPPATH."/helpers/Lavacharts/Lavacharts.php";

Then, I try to call it with :

$lava = new Lavacharts();

But it did'nt worked. So I tried :

$lava = new Khill\Lavacharts\Lavacharts();

But I got a fatal error : "Fatal error: Class 'Khill\Lavacharts\Volcano' not found in application/helpers/Lavacharts/Lavacharts.php on line 118"

I don't use Composer or Laravel. Is it mandatory ?

Thanks

@kevinkhill
Copy link
Owner

Yeaaaah, so when I was making this library, I didn't realize that all my class references were relying on composer's autoload functionality. I realized this once I was deep into refactoring for version 2, and so I decided that I would wait to fix this until the release. Now that V2 is in the wild, this is definitely on my list of todos. I'm looking into borrowing the symfony autoloader to allow use of the library in non composer/laravel environments.
I can make no promises for a completion date, but please keep an eye on the repo for updates! :)

@kevinkhill kevinkhill self-assigned this Dec 22, 2014
@kevinkhill
Copy link
Owner

I would highly recommend learning about composer and using it within your php development workflow. It makes adding packages and managing dependencies so much easier.

https://philsturgeon.uk/blog/2012/05/composer-with-codeigniter/

@kevinkhill kevinkhill reopened this Feb 8, 2015
@kevinkhill
Copy link
Owner

Please see Issue #24

@kevinkhill
Copy link
Owner

If you want to pull and test against the 2.4 branch, I have included a Psr4 Autoloader so you do not have to use composer (even though it is a great tool)
The only thing you need to do is also include the Carbon library before Lavacharts.

Here is an example:

<?php
  require_once('Carbon-1.18.0/src/Carbon/Carbon.php');
  require_once('lavacharts-2.4/src/Lavacharts.php');

  use \Carbon\Carbon;
  use \Khill\Lavacharts\Lavacharts;

  $lava = new Lavacharts;

  $dt = $lava->DataTable();

  $dt->addDateColumn('dates');
  $dt->addNumberColumn('numbers');

  for ($a=1; $a <= 30; $a++) {
    $dt->addRow([Carbon::parse($a.'-1-2015'), rand(100,200)]);
  }

  $lava->LineChart('Stuff')
       ->dataTable($dt);
?>

<doctype html>
<html>
  <head>
    <title>No Composer</title>
  </head>
  <body>
    <div id="chart"></div>

    <?php echo $lava->render('LineChart', 'Stuff', 'chart'); ?>
  </body>
</html>

@matthieubrunet
Copy link
Author

Thank you very much. In the meantime, I started my project directly with the google API. But for my next project, I will test Lavachart again :+)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants