L
L
lolka022019-02-14 12:41:07
Yii
lolka02, 2019-02-14 12:41:07

Why doesn't yii2 work with php version 5.4 even though it says 5.4 or more in the requirements?

when starting a site with php5.4, it gives
PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\\\ (T_NS_SEPARATOR) in /var/www/site/data/www/site .ru/vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php on line 5
I understand that this library works with php7, is there a way around this error on php5.4? or how to abandon this library, I didn't find it in composer-e.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Pavlenko, 2019-02-14
@Akdmeh

If the library works with PHP 7, then you need to either switch to PHP 7 or abandon the library.
The latest version of PHP 5.4 was released over three years ago. Now even 5.6 is no longer officially supported!
Are you really sure that it is still worth using such outdated software?

O
OnYourLips, 2019-02-14
@OnYourLips

The new version is not required by yii2 itself, but by other dependencies.
You need to update.
If the problem is in the hosting and it does not want to be updated (and sits on an unsupported version with vulnerabilities), then such a hoster needs to be changed.

M
Maxim Timofeev, 2019-02-14
@webinar

and how do you get around it, if if it is a third-party library. Will you get into the vendor to edit the code? And if you fix it, what is the probability that others will not go? If the library is under 7, then you need to use it on the seven. In addition, the seven is faster and generally better than 5.4. So I would decide the issue with the php version, not the library. Although, of course, there will always be a govnokod that will solve the issue with an error. But with such a meager description, it is difficult to advise something.

V
Vitsliputsli, 2019-02-14
@Vitsliputsli

It doesn't matter if it's a yii dependency or not. Yii2 can work with 5.4 so composer.json says "require": "php": ">=5.4.0". myclabs/deep-copy requires php 7.2 so it says "require": "php": "^7.2". Obviously, when installing yii2 and the myclabs/deep-copy component, resolving dependencies, the same composer will reject 5.4, because although this is sufficient for yii2, it is no longer sufficient for myclabs/deep-copy.
You need to update php, because even if you solve this problem, tomorrow there will be a similar one with another component.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question