首页 > 解决方案 > Laravel 5.5 and PHP incompatibility

问题描述

I was trying to setup a Laravel project in a server which I don't have ssh access, just cPanel access, so I came in with the problem that it seems that the server is not recognizing the right PHP version, Laravel's version I was trying to setup is 5.5. phpinfo() outputs version 7.0.22.

Inside cPanel there's a module called "PHP configuration" and it is set to version 7.

How can I solve this problem, I really want to use Laravel 5.5 or above, it is worth mentioning that I don't have contact with the server owner, I'm limited just to cPanel.

It is throwing the following error:

Parse error: syntax error, unexpected '?', expecting variable in /vendor/symfony/translation/Translator.php line 79

which is

public function __construct(?string $locale, ...

That is how I know it is not recognizing the right php version.

EDIT:

Just to clear out, I just thought that was the problem because I have had already that issue sometime in the past and read similar posts, but if that's not the case, I would appreciate that to be pointed out and not just silly jokes like "a bird flew", maybe other people are in the same problem and think of the same reason and this question could be useful to them.

标签: phplaravel

解决方案


原来是服务器的PHP版本与问题无关,问题是,由于我无法访问SSH,我必须在本地计算机上安装Laravel,然后将所有文件复制并放入服务器中, 但是我的电脑是 PHP 7.1,虽然 Laravel 的版本确实是 5.5,但 PHP 7.1 的一些特性被应用到了 Laravel 安装上。

所以解决方案就是在 PHP 7.0.* 安装中安装 Laravel 5.5,以使其在 PHP 7.0.22 的服务器中工作

相关 GitHub 问题 ~ https://github.com/laravel/framework/issues/23559


推荐阅读