douzhi7070 2010-07-27 13:52
浏览 17
已采纳

如何获取PHP脚本的依赖?

I am using a PHP library PHPExcel in my script. Now the library is very large nearly around 7MB and I dont think I am using all the features of it. I wish to make my script lightweightby delting the files in PHPExcel which I am not using.

How to achieve this?

  • 写回答

1条回答 默认 最新

  • douwen2158 2010-07-27 14:08
    关注

    PHPExcel uses an autoloader that only includes the files that your script actually uses, so the actual "in memory" size of the script is kept to a minimum.

    If you're not using any language other than English, then you can delete all the subdirectories in Classes/PHPExcel/locale... if you want another locale such as French, then you can delete all subdirectories except fr (saving about 0.5MB).

    However, I wouldn't recommend deleting anything else... especially without knowing exactly what you need.

    If disk space is absolutely critical, and you're only working with (for example) xls files, then you could delete all the other readers and writers (note that the PDF writer uses the HTML writer); but you must then explicitly identify which reader or writer you're going to use when reading rather than relying on the IOFactory's autodetect: so explicit syntax:

    $objReader = PHPExcel_IOFactory::createReader('Excel5');
    $objPHPExcel = $objReader->load("excel5File.xls");
    

    should be used instead of

    $objPHPExcel = PHPExcel_IOFactory::load("excel5File.xls");
    

    If you don't need the PDF writer, then deleting Classes/PHPExcel/Shared/PDF (tcpdf) will save about 4.5MB of disk

    However, I'd be reluctant to make any guarantees that you wouldn't run into problems somewhere.

    If you really need to shrink the size on disk, then stripping out comments from the code is going to reduce the size quite drastically... I'm sure there are scripts available that will do this.

    EDIT

    Paul Dixon's response to this question on stripping comments from a script might help minify to code on disk.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答