At our agency, we needed to install a Magento CE 2.4.5-p1 online shop on XAMPP (PHP 8.1) / Windows. Magento web shops are not designed for Windows or XAMPP, so there are a few special considerations. After we had resolved most of the difficulties (the correct c:\xampp\apache\conf\extra\httpd-vhosts.conf configuration, adjusting \vendor\magento\framework\View\Element\Template\File\Validator.php due to the different directory separator, etc.), one error remained.
Although we were able to manually deploy the static content in Developer Mode using bin/magento -f setup:static-content:deploy de_DE en_US, the assets in /pub/static/ were not generated simply by accessing the page. Only require-config.js was written. Among other things, the following error appeared in debug.log, which was generated in the file
\vendor\magento\framework\App\StaticResource.php
The error was:
adminhtml/Magento/backend/de_DE/Magento_ReCaptchaUser/css/recaptcha.css is wrong.
<pre>#1 Magento\Framework\App\Bootstrap->run() called at [pub\static.php:13]
</pre>
This was caused by the return value of the method
$this->isThemeAllowed($params['area']. DIRECTORY_SEPARATOR .$params['theme'])
being "false". This resulted from the Windows directory separator, which caused our online shop theme to be requested as:
frontend\Magento/luma
The system interpreted this as an unauthorized theme, although this does not make sense in this particular context, and therefore prevented the assets from being generated.
We therefore had to replace
if (!($this->isThemeAllowed($params['area'] . DIRECTORY_SEPARATOR . $params['theme'])
with
if (!($this->isThemeAllowed($params['area'] . '/' . $params['theme'])
With this change, the shop system was working again and the assets were generated on request in Developer Mode. And yes, of course: please do not make the correction directly in "vendor", but instead create your own extension that overrides the launch() function. However, that goes without saying. :-)
Encountered at our web agency in a Magento online shop running version 2.4.5-p1 on XAMPP on Windows.
