Symfony项目安装PHPUnit报错:proc_open(): CreateProcess失败,错误码-267
proc_open(): CreateProcess failed, error code -267 When Installing PHPUnit 5.x in Symfony Hey there, let's work through this frustrating error you're hitting while trying to set up PHPUnit 5.x via Composer in your existing Symfony project. That error code -267 is almost always a Windows-specific issue tied to process execution or system configuration. Here are actionable steps to resolve it:
Verify your PHP path configuration
Make sure your PHP executable's directory is added to your system'sPATHenvironment variable, and that the path doesn't contain spaces or special characters (these can trip upproc_open). Test this by opening a command prompt and runningphp -v— if it returns your PHP version, the path is set correctly. If not, add the PHP folder to yourPATHand restart your terminal.Clear Composer's cache
Corrupted cached dependencies can cause unexpected installation failures. Run this command to wipe the cache:composer clear-cacheThen re-run your original installation command:
composer require --dev phpunit/phpunit ^5Check Symfony and PHPUnit version compatibility
PHPUnit 5.x is compatible with Symfony 2.8 through 3.x. Double-check your project's Symfony version incomposer.json— if you're on a newer Symfony version (like 4+), PHPUnit 5.x won't work, and you'll need to target a compatible PHPUnit version instead.Run your terminal as Administrator
Permission restrictions can preventproc_openfrom creating necessary processes. Right-click your command prompt or PowerShell and select "Run as administrator", then try the installation command again.Temporarily disable antivirus/firewall
Some security tools interfere with Composer's ability to spawn processes. Temporarily turn off your antivirus or firewall, then attempt the installation. Remember to re-enable them once done.Manually specify the PHP executable path
If adjusting the systemPATHisn't working, you can directly reference the PHP executable in your Composer command. For example:C:\xampp\php\php.exe composer.phar require --dev phpunit/phpunit ^5Replace
C:\xampp\php\php.exewith the actual path to your PHP executable.
内容的提问来源于stack exchange,提问作者chouaib mehri

