- How do I install and use mitoteam/jpgraph in a Laravel project?
- Install via Composer with `composer require mitoteam/jpgraph`, then load JpGraph and modules anywhere in your code using `MtJpGraph::load(['bar', 'line'])` or `MtJpGraph::load('pie')`. The package preserves the original JpGraph API, so existing code works unchanged.
- Does this package work with Laravel 11 and PHP 8.5?
- Yes, the package supports PHP 8.5, which aligns with Laravel 11’s long-term support. Test with `strict_types=1` in your `php.ini` to avoid deprecation warnings in Extended Mode.
- Can I load only specific JpGraph modules (e.g., 'bar' or 'line')?
- Absolutely. Use `MtJpGraph::load(['bar'])` or `MtJpGraph::load(['line'])` to load only the modules you need. The package is idempotent—calling it multiple times won’t reload modules unnecessarily.
- How do I integrate this with Laravel’s service container?
- Register the package as a singleton in `AppServiceProvider` using `$this->app->singleton('jpgraph', function () { return new MtJpGraph(); })`. Then inject the service or create a facade for cleaner usage.
- Will this work for generating charts in PDFs or email attachments?
- Yes, this package is ideal for server-side rendering. Use it with Laravel’s `SnappyPDF`, `DomPDF`, or `Mailable` classes to embed charts in PDFs or emails without client-side dependencies.
- What are the risks of using Extended Mode with multiple modules?
- Extended Mode (`MtJpGraph::load(['bar', 'line'], true)`) may introduce side effects if modules conflict. Test thoroughly in staging, and consider caching chart outputs to reduce load.
- How do I handle font path issues (e.g., TTF_DIR not found)?
- Define the font directory before loading: `define('TTF_DIR', storage_path('fonts'));` then call `MtJpGraph::load()`. Validate the path in `AppServiceProvider` to avoid runtime errors.
- Is this package actively maintained? What if JpGraph updates?
- The package lacks recent commits (last release: 2026-04-06), so maintenance is unclear. Monitor the repo or fork it to handle future JpGraph updates or PHP version changes.
- Can I use this for high-traffic APIs (e.g., 1000+ charts/minute)?
- JpGraph’s GD-based rendering may struggle under heavy load. Cache outputs (e.g., Redis or file storage) and offload generation to Laravel Queues to improve scalability.
- What if GD library is missing on my Laravel Forge/Heroku server?
- Add `"ext-gd": "*"` to your `composer.json` requirements and reinstall dependencies. GD is required for JpGraph to render charts.