PHP-Report 安装及避坑指南

2025-8-16 / 0 评论 / 67 阅读

一、安装流程

  1. 获取源码
git clone https://github.com/jdorn/php-reports.gitcd php-reports
  1. 安装依赖(需已安装Composer)
composer install --no-dev
  1. 生成配置文件
# Linux / macOScp config/config.php.sample config/config.php# Windows 用 copy 命令copy config\config.php.sample config\config.php
  1. 修改配置文件数据库部分
'environments' => array( 'main'=>array( // Supports AdoDB connections 'ado'=>array( 'uri'=>'mysql://username:password@host:3306/dbname' ), // Supports and PDO database 'pdo'=>array( 'dsn'=>'mysql:host=127.0.0.1;port=3306;dbname=dbname', 'user'=>'root', 'pass'=>'root', ), // Supports MongoDB 'mongo'=>array( 'host'=>'127.0.0.1', 'port'=>'3306' ), ), ),
  1. 给缓存目录写权限
chmod -R 777 cache
  1. Nginx网站配置文件中,添加一段 :
try_files $uri $uri/ /index.php?$query_string;

​ 位置如下:

server { listen 80; server_name reports.local; root /var/www/php-reports/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; }}
  1. mongodb拓展开启:在php.ini中添加一行
extension=mongodb
  1. 解决报表内容中文乱码

编辑源码文件:PHP-Reports\lib\PhpReports\ReportValue.php 位置在72行左右

源代码:return utf8_encode($value);

修改为:return $value;


评论一下?

OωO
取消