phpbu
phpbu copied to clipboard
PHP Parse error: syntax error, unexpected 'static' (T_STATIC) in phar (using phpbu-6.0.20.phar with php 7.4.33)
Well basically I've got PHP 7.4.33 running.
I've downloaded the phar file from https://phar.phpbu.de/phpbu-6.0.20.phar that apparently is compatible with my php version.
Then when I run it:
-bash-4.2$ /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/phpbu-6.0.20.phar --configuration=/var/www/vhosts/example.com/httpdocs/config/phpbu.xml
phpbu 6.0.20 by Sebastian Feldmann and contributors.
Runtime: PHP 7.4.33
Configuration: /var/www/vhosts/example.com/httpdocs/config/phpbu.xml
PHP Parse error: syntax error, unexpected 'static' (T_STATIC) in phar:///var/www/vhosts/example.com/httpdocs/phpbu-6.0.20.phar/lib/symfony/process/Process.php on line 190
But the same phpbu version installed with composer as a dependency inside my php application, it works!
-bash-4.2$ /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/vendor/bin/phpbu --configuration=/var/www/vhosts/example.com/httpdocs/config/phpbu.xml
phpbu 6.0.20 by Sebastian Feldmann and contributors.
Runtime: PHP 7.4.33
Configuration: /var/www/vhosts/example.com/httpdocs/config/phpbu.xml
Time: 2 seconds, Memory: 16.00MB
backup mysql_main_db: OK
| executed | skipped | failed |
----------+----------+---------+--------+
checks | 0 | | 0 |
crypts | 0 | 0 | 0 |
syncs | 1 | 0 | 0 |
cleanups | 1 | 0 | 0 |
----------+----------+---------+--------+
backup mysql_stats_db: OK
| executed | skipped | failed |
----------+----------+---------+--------+
checks | 0 | | 0 |
crypts | 0 | 0 | 0 |
syncs | 1 | 0 | 0 |
cleanups | 1 | 0 | 0 |
----------+----------+---------+--------+
backup files_daily_uploads: OK
| executed | skipped | failed |
----------+----------+---------+--------+
checks | 0 | | 0 |
crypts | 0 | 0 | 0 |
syncs | 1 | 0 | 0 |
cleanups | 1 | 0 | 0 |
----------+----------+---------+--------+
backup files_incremental_uploads_documentacion: OK
| executed | skipped | failed |
----------+----------+---------+--------+
checks | 0 | | 0 |
crypts | 0 | 0 | 0 |
syncs | 1 | 0 | 0 |
cleanups | 1 | 0 | 0 |
----------+----------+---------+--------+
OK (4 backups, 0 checks, 0 crypts, 4 syncs, 4 cleanups)
So why composer installed version is working but the downloaded phar doesn't?
That error message looks like the 6.0.20 release .phar file was compiled with dependencies (i.e. symfony/process) that are "too new" and don't support PHP 7.x anymore.
I don't know the exact build process, but my guess is that it was done on a system that had PHP 8.X installed, so Composer thought it could fetch modern dependency versions, which were then baked into the release.
Yes since php 6.0.20 the PHAR requires php 8.0