One of the things Magento 2.1 doesn’t bring to the table is the ability to symlink your modules and other components. It’s hard to tell if this is a deliberate omission, or just something that’s not a priority for the development team and keeps getting lost in the shuffle. If you checkout the Context section of this GitHub bug, you can see Magento’s template validation does still check the allow symlinks setting, but the immediately does another check that could never pass with a module available via a symlink outside the Magento system’s folder structure.
Maddening, but something we can at least work around. If we create a module that has a plugin for the MagentoFrameworkViewElementTemplateFileValidator
class
pestle.phar generate_module Pulsestorm DisableTemplateValidation 0.0.1
pestle.phar generate_plugin_xml Pulsestorm_DisableTemplateValidation MagentoFrameworkViewElementTemplateFileValidator PulsestormDisableTemplateValidationPluginMagentoFrameworkViewElementTemplateFileValidator
php bin/magento module:enable Pulsestorm_DisableTemplateValidation
php bin/magento setup:upgrade
and then create an after plugin for the isValid
method that always returns true.
#File: app/code/Pulsestorm/DisableTemplateValidation/Plugin/Magento/Framework/View/Element/Template/File/Validator.php
<?php namespace PulsestormDisableTemplateValidationPluginMagentoFrameworkViewElementTemplateFile;
class Validator
{
public function afterIsValid($subject, $result)
{
$result = true;
return $result;
}
}
We should be all set.
This probably isn’t something you want to do in a production system – loading templates outside of the Magento root is one step in a multi-step attack vector on Magento systems, but for developers working locally this seems like an OK work-around until Magento decides what they’re going to do w/r/t symlinks.