You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.6与PHP版本兼容问题求助:PHPUnit运行报错

Troubleshooting Laravel 5.6 & PHP Compatibility Issues

Let’s break down your two issues and fix them step by step:

1. PHP 7.1.14 and Laravel 5.6 Compatibility

First, let’s clear up a misconception: Laravel 5.6’s official minimum requirement is PHP >=7.1.3, so PHP 7.1.14 should fully support it. If you encountered issues with this combination, it’s likely not due to the version itself—check for other problems like misconfigured PHP extensions (e.g., missing mbstring, openssl, or PDO), outdated Composer dependencies, or a mismatch between your web server PHP version and CLI PHP version (more on that below).

2. Parse Error with Null Coalescing Operator (??) in PHPUnit

Your error message mentions a syntax error on the line return app('cache')->get($arguments[0], $arguments[1] ?? null);—but the ?? (null coalescing) operator was introduced in PHP 7.0, so PHP 7.2.4 should handle it without issues. Here’s why you’re seeing this error:

The Root Cause

PHPUnit runs via the command line interface (CLI), and it’s possible that your CLI is using an older version of PHP (like PHP 5.x) instead of the 7.2.4 version your web server uses. This is a common setup issue, especially with tools like Laragon where multiple PHP versions might be installed.

How to Fix It

  • Check your CLI PHP version: Open your terminal and run:

    php -v
    

    If the output shows a version lower than 7.0, that’s the problem.

  • Switch to the correct PHP version in Laragon: Use the Laragon menu to select PHP 7.2.4, then restart your terminal to apply the change.

  • Run PHPUnit with the correct PHP executable: If switching the default CLI version isn’t working, specify the full path to your PHP 7.2.4 executable when running PHPUnit:

    C:\laragon\bin\php\php7.2.4\php.exe vendor/bin/phpunit
    
  • Verify dependencies: Run this command to ensure all your Composer packages are compatible with your PHP version:

    composer check-platform-reqs
    

By ensuring PHPUnit uses PHP 7.0 or higher, the ?? operator error should disappear.

内容的提问来源于stack exchange,提问作者Mikail G.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:13:59