I have Laravel 5.4 installed on PHP 5.6.4 server, and i can't start the app. Everything works ok locally with the same configuration, but on the server i get this error:
(1/1) FatalErrorException syntax error, unexpected '?', expecting variable (T_VARIABLE)
in PDOConnection.php line 24
CLI version is 7.2 on the server, and phpinfo() shows 5.6.40. The error shows on pages where DB access is needed. When there's no DB requests it works fine.
Thanks :)
PDOConnection.php
is a file from doctrine/dbal
package, and its line 24 is incompatible with PHP 5.4 (using ?array
).
Laravel 5.4 has doctrine/dbal~2.5
in its require-dev
, but in version 2.5 there is no such issue ( line 40 ).
It seems that you have to delete vendor
folder and run composer install
again, that will install needed dependencies.
Added:
@aynber pointed that your issue is with installing dependencies with PHP 7.2 and running on PHP 5.6, so after removing vendor
folder and before reinstalling you should add this to your composer.json
:
"config": {
"platform": {
"php": "5.6.40"
}
}
Are you sure you're using Laravel 5.4? Laravel 5.4 should be using doctrine/dbal@~2.5
where there is only a comment on line 24 . It appears you are using at least version 2.9, which uses nullable types which is only available in PHP 7.1+.
Your options:
laravel/framework@5.4
Thanks for your help, i fixed the problem.
I cleared the composer cache with 'composer clearcache', then i ran:
composer which, which returned the composer path
and then i ran
php -d allow_url_fopen=on COMPOSER_PATH_FROM_PREV_STEP update
and it updated all dependencies to work with PHP5.6 :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.