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

Ubuntu16.04LTS下PhpStorm2018.1配置php7.0解释器报错求助

Fixing "Failed to parse validation script output" in PhpStorm 2018.1 with PHP 7.0 on Ubuntu 16.04

Hey there, let’s work through this PhpStorm interpreter validation error step by step, based on your setup details:

Step 1: Verify You’re Selecting the Exact PHP 7.0 Binary

Even though which php points to /usr/bin/php, symlinks can sometimes cause confusion in PhpStorm. Let’s explicitly target PHP 7.0:

  1. Open PhpStorm and navigate to File > Settings > Languages & Frameworks > PHP
  2. Click the ... button next to "CLI Interpreter"
  3. Select Local from the dropdown, then browse directly to /usr/bin/php7.0 (not just /usr/bin/php)
  4. Save the configuration and try validating again

Step 2: Align PhpStorm with Your CLI’s php.ini

PhpStorm might be loading a different php.ini file than your terminal’s PHP instance. Let’s sync them:

  1. Run this in your terminal to find your active CLI php.ini:
    php --ini
    
    Note the path listed under Loaded Configuration File (e.g., /etc/php/7.0/cli/php.ini)
  2. Back in PhpStorm’s CLI Interpreter settings, go to the Configuration Options tab
  3. Add a new entry: -c with the value of your loaded php.ini path (e.g., /etc/php/7.0/cli/php.ini)
  4. Apply changes and re-validate

Step 3: Eliminate Unwanted PHP CLI Output

The "Failed to parse" error almost always happens when PHP outputs extra text (warnings, notices, or custom startup messages) before the clean JSON PhpStorm expects. Here’s how to fix it:

  1. Test if PHP outputs extra content by running:
    php -r "echo json_encode(['test' => 'valid']);"
    
    If the output starts with warnings/errors instead of pure JSON, that’s your culprit.
  2. Fix this by either:
    • Editing /etc/php/7.0/cli/php.ini to set display_errors = Off
    • Adding a configuration option in PhpStorm’s CLI settings: -d display_errors=0

Step 4: Check for Auto-loaded PHP Scripts

If you have an auto_prepend_file configured in php.ini, it might inject extra output. Run this to check:

php -i | grep auto_prepend_file

If a path is listed, either comment out that line in your cli/php.ini or adjust the script to not output anything when running via CLI.


内容的提问来源于stack exchange,提问作者Prasad Sawant

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 07:36:32