Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with PHP 5.x broken #2055

Open
SamLowrie opened this issue Apr 12, 2021 · 6 comments
Open

Compatibility with PHP 5.x broken #2055

SamLowrie opened this issue Apr 12, 2021 · 6 comments

Comments

@SamLowrie
Copy link

I have to maintain some outdated PHP 5.x installations.
The laminas libraries break the compatibility with PHP 5.x for me, as they require php >=v 7. Requirements for PHP in file README.md should probably be updated.

@liborm85
Copy link
Contributor

PHPWord works correctly with PHP 5.3+. Add information, if something doesn't work..

@SamLowrie
Copy link
Author

SamLowrie commented Apr 14, 2021

When installing via composer 0.18.1, the libraries vendor/laminas/* are installed and included in the autoloader. At least the file vendor/laminas/laminas-zendframework-bridge/src/Autoloader.php contains code which does not run in PHP 5.3:

Line 15++: use function ... (>=5.6)
Line 49, 114, ...: []-Shortcut operator for array creation (>=5.4)

I had a quick look into the other files from the laminas libraries ... they all seem to have the same problem.

@liborm85
Copy link
Contributor

This bug is introduced in 0.18.1 version via PR #2032.
Add this to your composer.json to disable unnecessary package, to fix it:

    "replace": {
        "laminas/laminas-zendframework-bridge": "*"
    },

@SamLowrie
Copy link
Author

Thanks for the fast answer! 👍

I managed to get it to run, but I also had to remove the laminas-escaper with

  "replace": {
        "laminas/laminas-zendframework-bridge": "*",
        "laminas/laminas-escaper": "*"
    }

Now PHPOffice seems to work, not sure where the escaper library is actually needed. I am only using the template part of PHPOffice.

@liborm85
Copy link
Contributor

PHPWord using laminas/laminas-escaper library with minimal version 2.2, which is compatible with PHP 5.3, see https://github.com/laminas/laminas-escaper/blob/2.2.10/composer.json#L28

@SamLowrie
Copy link
Author

Ah, ok. Then an older version of the laminas escaper library must be installed (2.2), as the latest version also uses array declaration shortcut operators (>=5.4).

I got everything running with php 5.3.x with following composer.json config:

{
    "require": {
        "phpoffice/phpword": "^0.18.1",
        "laminas/laminas-escaper": "2.2"
    },
    "replace": {
        "laminas/laminas-zendframework-bridge": "*"
    }
}

Thanks again for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants