Phpspreadsheet: PHPSpreadsheet shouldn't have gd as dependency

Created on 9 Feb 2018  路  7Comments  路  Source: PHPOffice/PhpSpreadsheet

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

I don't think PHPSpreadsheet should have ext-gd as a dependency.
PHPExcel didn't have it as dependency.
Most of what PHPSpreadsheet can do doesn't require gd.
The confusion is also visible in the composer.json as ext-gd and ext-dom are both in "dependency" and "suggests".

What is the current behavior?

PHPSpreadsheet requires ext-gd.

What are the steps to reproduce?

composer install

Which versions of PhpSpreadsheet and PHP are affected?

Tested with PHPSpreadsheet 1.1.0

Most helpful comment

I also find weird to have this as requirement instead as a suggestion. We use the lib to process text only spreadsheets. Our servers do not have GD, we shouldn't be forced to install it for a feature we won't use.

All 7 comments

Some of the features do indeed require gd, and as such the entire package does require it. They are quite a few extensions required, but all of them are rather common and should be available, or easily installable, in most environnements.

I second this. I'm wanting to move from PHPExcel to PHPSpreadsheet but our servers do not have GD installed. Seeing as we don't use any GD requiring features, this is particularly obnoxious.

@PowerKiKi It's sad that if you're already using ImageMagick you're forced to also install GD. IMHO, imaging library should be not a requirement, but rather a suggestion, if someone wants to use certain features.

I also find weird to have this as requirement instead as a suggestion. We use the lib to process text only spreadsheets. Our servers do not have GD, we shouldn't be forced to install it for a feature we won't use.

@PowerKiKi I think this should be reconsidered. In our case, we have an application with web servers, worker servers and a test server, also, we process our images with Imagick. It may not be that cumbersome to install GD once, even with the current justification, but on bigger infrastructures it gets really annoying.

Many use-cases would involve reading user submitted spreadsheet files and there is no way to ensure that those do not contain images before actually reading them.

For now, Xls reader has a clear, hard dependency on GD. If GD is not present and you try to read a XLS file containing an image it will crash. This would be a very poor experience for the user and the developer where some files would work and other would not.

If your infrastructure is big enough to be a worry, then it should be automated anyway to be replicable consistently and predictability.

Couldn't it be a suggested package? If a function of the library GD is called, it could be wrapped to check if the function exists, and return a controlled exception explaining that you need the GD extension to open that kind of documents. It seems a little overkill to make it a hard requirement for everybody.

Was this page helpful?
0 / 5 - 0 ratings