mitoteam/jpgraph 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mitoteam/jpgraph

Composer 安装命令:

composer require mitoteam/jpgraph

包简介

JpGraph library composer package with PHP 8.5 support

关键字:

README 文档

README

Packagist Version Packagist PHP Version Support Packagist Total Downloads Packagist Monthly Downloads

GitHub Version GitHub Release Date GitHub code size in bytes GitHub contributors GitHub commit activity

JpGraph library version: 4.4.3

PHP versions support: from 5.5 to 8.5. Original notes about PHP versions.

Usage with composer

This package is a helper to load original JpGraph library after declaring it as your dependency in composer.json:

composer require mitoteam/jpgraph

Then you can load library from anywhere in your code:

use mitoteam\jpgraph\MtJpGraph;

// load library and modules
MtJpGraph::load();                # not really useful without modules
//or
MtJpGraph::load('bar');           # load with single module
//or
MtJpGraph::load(['bar', 'line']); # load with several modules
//or
MtJpGraph::load(['bar', 'line'], true); # load with several modules in Extended Mode (see below)

//using original JpGraph classes
$graph = new Graph(200, 300);

You can call MtJpGraph::load() method as many times as you need everywhere in your code. Internally it checks if library or module was already loaded and does not load it another time.

Usage without composer

Download latest version archive from Releases page and unpack it.

Version numbers

We started with version 4.3.5 as latest available library version in time we started. But we need to make some patches to original library (for example to support latest PHP versions). So we had to switch to own version numbers to be able to release updates.

At 2022-02-25 we decided to switch to version number 10.0.0 to leave some margin in numbering from original library v4.3.5.

Current version numbers:

  • Version 10.x of this package is the latest version of JpGraph library with php 8.2-8.5 compatibility patches (code in "main" branch). Can be loaded in Extended Mode (see below).
  • Version 4.x of this package provides latest version of original JpGraph library as-is without any compatibility patches (code in "original" branch).

All changes to the original library can be examined as difference between main and original branches.

Overriding jpgraph's settings

A lot of original jpgraph's settings are defined as constants in jpg-config.inc.php and jpgraph_ttf.inc.php files. We wrapped all these constants definitions with if(!defined()) checks. So you can define them with required values before loading MtJpGraph. See Issue #24 for the details.

Code example:

use mitoteam\jpgraph\MtJpGraph;

//first define required constants
define('CACHE_FILE_GROUP', 'supergroup');

// and then load library and modules
MtJpGraph::load('bar');

Extended Mode

We started with just patches for compatibility with recent PHP versions. Before version 10.3 there were no any changes to original code except adding some typecasting or declaring some class members explicitly.

But after library was used wider there were some bugs discovered in original code. We aware to change functionality of the original library so Extended Mode was introduced in version 10.3.0. Now you can pass true as second argument to MtJpGraph::load() method to enable Extended Mode. This will enable several more patches to the original code to overcome some bugs.

Extended Mode is disabled by default, you can enable it explicitly only.

Custom exception handler

jpgraph sets custom exceptions handler internally to be able to draw error message in picture if some exception pops up. It restores old exception handler if any was set after exception processing. This behavior can interfere with some tests runners which are using own exception handlers. For example phpunit marks tests as risky with message "Test code or tested code did not remove its own exception handlers".

It is possible to disable custom jpgraph's exceptions handler by calling explicitly MtJpGraph::setSkipExceptionHandler(true); before first call to MtJpGraph::load(). MtJpGraph checks if PHPUNIT_COMPOSER_INSTALL constant defined and disables jpgraph's exceptions handler implicitly for phpunit.

Please note: this intended to be used in tests context only and should not be used in production mode.

Links

Star History

Star History Chart

mitoteam/jpgraph 适用场景与选型建议

mitoteam/jpgraph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 794.32k 次下载、GitHub Stars 达 56, 最近一次更新时间为 2022 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「jpgraph」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mitoteam/jpgraph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mitoteam/jpgraph 我们能提供哪些服务?
定制开发 / 二次开发

基于 mitoteam/jpgraph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 794.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 60
  • 点击次数: 25
  • 依赖项目数: 9
  • 推荐数: 7

GitHub 信息

  • Stars: 56
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: QPL-1.0
  • 更新时间: 2022-01-16