MarBer
MarBer

Reputation: 595

Yii2 init error on PHP7

I've a problem when i try to switch my project from dev enviroment to prod, the project is a git repository I push to my server, now I need to switch to production and I try to runphp init on server but all time I receive the same error:

Parse error: syntax error, unexpected T_FUNCTION in /my/root/path/init on line 70

where /my/root/path/ is the base path where I push code.

Someone have any idea about this error?

Upvotes: 1

Views: 376

Answers (1)

Bizley
Bizley

Reputation: 18021

Based on my previous answer and the comment:

Try

array_walk($skipFiles, function(&$value, $key, $data) {
    $value = $data[1] . '/' . $value;
}, [$env, $root]);

@Marber: Return the same error, a similar solution is function resolveBug($value) { $value = "$root/$value"; } array_walk($skipFiles, resolveBug($value)); and this resolve the bug but the procedure generate anothe error on line 81: Parse error: syntax error, unexpected '['... and the code is $callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable', 'createSymlink'];

I'm guessing there is PHP 7 on the CGI side and CLI is PHP < 5.3 and that is why console commands don't work.

Check your console PHP version by running

php -v

in console.

Upvotes: 2

Related Questions