Skip to content

Commit

Permalink
Drop PHP 8.0 support
Browse files Browse the repository at this point in the history
This is according to our formal, published, policy to only support
EOL PHP after 6 months.

See https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support

Also consolidate documentation in a single place, not in the README,
because it's a pain to maintain almost-duplicated-but-not-really
documentation.
  • Loading branch information
PowerKiKi committed May 11, 2024
1 parent dbed77b commit 8968062
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 104 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
experimental:
- false
php-version:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
Expand Down Expand Up @@ -174,7 +173,7 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Code Version Compatibility check with PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 8.0-
run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 8.1-

phpstan:
runs-on: ubuntu-latest
Expand Down
73 changes: 1 addition & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,9 @@
PhpSpreadsheet is a library written in pure PHP and offers a set of classes that
allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.

## PHP Version Support

LTS: Support for PHP versions will only be maintained for a period of six months beyond the
[end of life](https://www.php.net/supported-versions) of that PHP version.

Currently the required PHP minimum version is PHP __8.0__, and we [will support that version](https://www.php.net/eol.php) until May 2024.

See the `composer.json` for other requirements.

## Installation

Use [composer](https://getcomposer.org) to install PhpSpreadsheet into your project:

```sh
composer require phpoffice/phpspreadsheet
```

If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
```json
{
"config": {
"platform": {
"php": "8.0"
}
}
}
```
and then run
```sh
composer install
```
to ensure that the correct dependencies are retrieved to match your deployment environment.

See [CLI vs Application run-time](https://php.watch/articles/composer-platform-check) for more details.

### Additional Installation Options

If you want to write to PDF, or to include Charts when you write to HTML or PDF, then you will need to install additional libraries:

#### PDF

For PDF Generation, you can install any of the following, and then configure PhpSpreadsheet to indicate which library you are going to use:
- mpdf/mpdf
- dompdf/dompdf
- tecnickcom/tcpdf

and configure PhpSpreadsheet using:

```php
// Dompdf, Mpdf or Tcpdf (as appropriate)
$className = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class;
IOFactory::registerWriter('Pdf', $className);
```
or the appropriate PDF Writer wrapper for the library that you have chosen to install.

#### Chart Export

For Chart export, we support following packages, which you will also need to install yourself using `composer require`
- [jpgraph/jpgraph](https://packagist.org/packages/jpgraph/jpgraph) (this package was abandoned at version 4.0.
You can manually download the latest version that supports PHP 8 and above from [jpgraph.net](https://jpgraph.net/))
- [mitoteam/jpgraph](https://packagist.org/packages/mitoteam/jpgraph) - up to date fork with modern PHP versions support and some bugs fixed.

and then configure PhpSpreadsheet using:
```php
// to use jpgraph/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
//or
// to use mitoteam/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class);
```

One or the other of these libraries is necessary if you want to generate HTML or PDF files that include charts; or to render a Chart to an Image format from within your code.
They are not necessary to define charts for writing to `Xlsx` files.
Other file formats don't support writing Charts.
See the [install instructions](https://phpspreadsheet.readthedocs.io/en/latest/#installation).

## Documentation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"config": {
"platform": {
"php" : "8.0.99"
"php" : "8.1.99"
},
"sort-packages": true,
"allow-plugins": {
Expand Down Expand Up @@ -65,7 +65,7 @@
]
},
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
Expand Down
21 changes: 18 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 47 additions & 16 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allow you to read and write various spreadsheet file formats such as Excel and L

## Software requirements

PHP version 8.0 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by
PHP version 8.1 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by
composer. See the `require` section of [the composer.json file](https://github.com/PHPOffice/PhpSpreadsheet/blob/master/composer.json)
for details.

Expand All @@ -33,7 +33,7 @@ for details.
LTS: Support for PHP versions will only be maintained for a period of six months beyond the
[end of life of that PHP version](https://www.php.net/eol.php).

Currently, the required PHP minimum version is PHP 8.0.
Currently, the required PHP minimum version is __PHP 8.1__, and we [will support that version](https://www.php.net/eol.php) until June 2026.

Support for PHP versions will only be maintained for a period of six months beyond the
[end of life](https://www.php.net/supported-versions) of that PHP version.
Expand All @@ -54,23 +54,54 @@ Or also download the documentation and samples if you plan to use them:
composer require phpoffice/phpspreadsheet --prefer-source
```

If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
```json
{
"config": {
"platform": {
"php": "8.0"
}
}
}
If you are building your installation on a development machine that is on a different PHP version to the server where it
will be deployed, or if your PHP CLI version is different from your run-time such as `php-fpm` or Apache's `mod_php`,
then you might want to configure composer for that.
See [composer documentation](https://getcomposer.org/doc/06-config.md#platform)
on how to edit your `composer.json` to ensure that the correct dependencies are retrieved to match your deployment
environment.

See [CLI vs Application run-time](https://php.watch/articles/composer-platform-check) for more details.

### Additional Installation Options

If you want to write to PDF, or to include Charts when you write to HTML or PDF, then you will need to install additional libraries:

#### PDF

For PDF Generation, you can install any of the following, and then configure PhpSpreadsheet to indicate which library you are going to use:
- mpdf/mpdf
- dompdf/dompdf
- tecnickcom/tcpdf

and configure PhpSpreadsheet using:

```php
// Dompdf, Mpdf or Tcpdf (as appropriate)
$className = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class;
IOFactory::registerWriter('Pdf', $className);
```
and then run
```sh
composer install
or the appropriate PDF Writer wrapper for the library that you have chosen to install.

#### Chart Export

For Chart export, we support following packages, which you will also need to install yourself using `composer require`
- [jpgraph/jpgraph](https://packagist.org/packages/jpgraph/jpgraph) (this package was abandoned at version 4.0.
You can manually download the latest version that supports PHP 8 and above from [jpgraph.net](https://jpgraph.net/))
- [mitoteam/jpgraph](https://packagist.org/packages/mitoteam/jpgraph) - up to date fork with modern PHP versions support and some bugs fixed.

and then configure PhpSpreadsheet using:
```php
// to use jpgraph/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
//or
// to use mitoteam/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class);
```
to ensure that the correct dependencies are retrieved to match your deployment environment.

See [CLI vs Application run-time](https://php.watch/articles/composer-platform-check) for more details.
One or the other of these libraries is necessary if you want to generate HTML or PDF files that include charts; or to render a Chart to an Image format from within your code.
They are not necessary to define charts for writing to `Xlsx` files.
Other file formats don't support writing Charts.

## Hello World

Expand Down
8 changes: 3 additions & 5 deletions docs/topics/reading-and-writing-to-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,10 @@ $reader->loadIntoExisting("05featuredemo.csv", $spreadsheet);

Line endings for Unix (`\n`) and Windows (`\r\n`) are supported.

Mac line endings (`\r`) are supported as long as PHP itself
supports them, which it does through release 8.0.
Support for Mac line endings is deprecated for 8.1,
Support for Mac line endings (`\r`) is deprecated since PHP 8.1,
and is scheduled to remain deprecated for all later PHP8 releases;
PhpSpreadsheet will continue to support them for 8.*.
Support is scheduled to be dropped with release 9;
PhpSpreadsheet will continue to support them for PHP 8.*.
Support is scheduled to be dropped with PHP 9;
PhpSpreadsheet will then no longer handle CSV files
with Mac line endings correctly.

Expand Down
2 changes: 1 addition & 1 deletion samples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once 'Header.php';

$requirements = [
'PHP 8.0' => version_compare(PHP_VERSION, '8.0', '>='),
'PHP 8.1' => version_compare(PHP_VERSION, '8.1', '>='),
'PHP extension XML' => extension_loaded('xml'),
'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
'PHP extension mbstring' => extension_loaded('mbstring'),
Expand Down
5 changes: 2 additions & 3 deletions src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public function __construct($separators, ...$formatBlocks)
private function mapFormatBlocks(DateTimeWizard|string $value): string
{
// Any date masking codes are returned as lower case values
if (is_object($value)) {
// We can't explicitly test for Stringable until PHP >= 8.0
return $value;
if ($value instanceof DateTimeWizard) {
return $value->__toString();
}

// Wrap any string literals in quotes, so that they're clearly defined as string literals
Expand Down

0 comments on commit 8968062

Please sign in to comment.