Civi cannot be installed on Local (previously Local By Flywheel) on Windows
Installing on Local fails due a issue when parsing the schema xml files. On Windows, anyway. Flagging this because Local seems to be increasingly popular as a dev tool - plus is used by people on Flywheel / WP Engine.
What happens is:
- CRM_Core_CodeGen_Util_Xml::parse() reads xml/schema/Schema.xml. Schema.xml uses xi:include tags to include all the other xml schema files in the relevant subdirectories.
- These inclusions are processed in parse() by a DomDocument object running xinclude(). This fails with a "failed to load external entity" error. Process Monitor shows that it's looking in the wrong directory: it looks for them in the root, rather than under xml/schema.
There's a not-great workaround:
Edit CRM_Core_CodeGen_Util_Xml::parse() and manually set the DomDocument->documentURI to a relative path instead of the absolute path it uses by default. It needs to be relative to the current PHP working directory, which is wp-admin at this point. So under a default WP install this would be: '../wp-content/plugins/civicrm/civicrm/xml/schema/Schema.xml'
I haven't figured out the cause yet. I thought it might be to do with spaces in the directory path (Local uses a folder called "Local Sites" by default on Windows), but it happens outside of that directory too.
The problem doesn't happen XAMP under Windows, so it must be something about the Local setup. I believe it uses Docker behind the scenes. I contacted Local support to see if they had any known issues with xi:include, but no joy.
I'm out of ideas at the moment. Raising an issue so it's at least recorded.