yireo / magento2-devhacks
Some hacks to make M2 development easier
Package info
github.com/yireo/Yireo_DevHacks
Type:magento2-module
pkg:composer/yireo/magento2-devhacks
Requires
- php: >=8.2 <8.6
- ext-pcre: *
- magento/framework: ^100.0|^101.0|^102.0|^103.0
- magento/module-deploy: ^100.0
- magento/module-store: ^100.0|^101.0
Requires (Dev)
- phpunit/phpunit: ^9.5 || ^10.5
- yireo/magento2-integration-test-helper: ~0.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Magento 2 module with development hacks, that came in handy for myself.
Warning: development only
Never install this module in production, or on any publicly reachable environment. It deliberately disables security checks of the Magento core.
The command bin/magento yireo_devhacks:copy_hacks overwrites the following core files in vendor/magento/framework with the files in Copy/:
Filesystem/Directory/PathValidator.php: path validation is disabled, so directory objects no longer block path traversal;View/Element/Template/File/Validator.php: any file on disk is accepted as a template;Filesystem/Driver/File.php: any path starting with/data/git/yireois returned as absolute path without validation. This file is a frozen copy of the core driver and replaces newer core versions (including security fixes).
These overwrites stay in place after the module is disabled or removed. Restore the original core files with:
composer reinstall magento/framework
Consider the core alternatives first:
bin/magento config:set dev/template/allow_symlink 1to allow templates outside of the Magento root;bin/magento setup:static-content:deploy --no-html-minifyto skip HTML minification.
The other hacks of this module (skipping HTML minification and throwing an exception for blocks without a template file) are only active in developer mode.
Installation
Use the following commands to install:
composer require yireo/magento2-devhacks:@dev --dev
Enable this module:
./bin/magento module:enable Yireo_DevHacks
./bin/magento setup:upgrade
Skip template path validation
The core checks whether PHTML templates are in the path of the Magento core. When using the composer feature path to symlink a local repository to Magento, while the path is outside of Magento, this throws an exception. This module simply skips the entire logic. No configuration needed. Bam.
Toggle TESTS_CLEANUP in integration tests configuration
Moved to separate Yireo_IntegrationTestHelper module instead.