Warning: file_put_contents in plugin-list.php and PluginListGenerator.php in Magento 2 while compiling

While you are running your Magento 2 website in XAMPP and you run “php bin/magento setup:di:compile” and you see the error in line number 412 in vendor/magento/framework/Interception/PluginListGenerator.php file then this blog post helps you to fix this issue in your localhost Magento setup.

This is a known issue when you run Magento 2.4.x in your local host under XAMPP. You may face an error message as below when you run the compilation

Warning: file_put_contents(D:/xampp8/htdocs/m245/generated/metadata/primary|global|plugin-list.php): failed to open stream: No such file or directory in D:\xampp8\htdocs\m245\vendor\magento\framework\Interception\PluginListGenerator.php on line 412

Follow the below steps to fix the compilation issue in Magento 2 XAMPP setup

Step 1: Open PluginListGenerator.php file from /vendor/magento/framework/Interception/ location

Step 2: Then replace the below code

$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;

With below

$cacheId = implode('-', $this->scopePriorityScheme) . "-" . $this->cacheId;

After saving this file, you can try again by running di:compile; it should work without any issues.