Last active
April 24, 2020 08:29
-
-
Save diogomascarenha/f4b8d2bff25c99efe69e64bf789ae137 to your computer and use it in GitHub Desktop.
Script to replace PHPStorm configuration to add all php files from vendor directory to (Languages & Frameworks > PHP > Debug > Step Filters > Files)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $xmlConfigurationPath = __DIR__. '/.idea/php.xml'; | |
| $xml = simplexml_load_file($xmlConfigurationPath); | |
| $node = $xml->xpath('component[@name="PhpStepFilterConfiguration"]'); | |
| if(!empty($node)) | |
| { | |
| unset($node[0][0]); | |
| } | |
| $now=date('YmdHis'); | |
| $xmlConfigurationPathInfo = pathinfo($xmlConfigurationPath); | |
| $xmlConfigurationPathBackup = $xmlConfigurationPathInfo['dirname'] | |
| . DIRECTORY_SEPARATOR | |
| . $xmlConfigurationPathInfo['filename'] | |
| .'.' | |
| . $now | |
| . '.' | |
| . $xmlConfigurationPathInfo['extension']; | |
| $resultCopy = copy($xmlConfigurationPath,$xmlConfigurationPathBackup); | |
| $component = $xml->addChild('component'); | |
| $component->addAttribute('name','PhpStepFilterConfiguration'); | |
| $skippedFiles = $component->addChild('skipped_files'); | |
| $pathSkipFiles = __DIR__ . DIRECTORY_SEPARATOR. 'vendor'; | |
| $directoryIterator = new RecursiveDirectoryIterator($pathSkipFiles); | |
| $iterator = new RecursiveIteratorIterator($directoryIterator); | |
| $regexIterator = new RegexIterator($iterator, '/\.php$/'); | |
| $regexIterator->setFlags(RegexIterator::USE_KEY); | |
| foreach ($regexIterator as $file) { | |
| $skippedFile = $skippedFiles->addChild('skipped_file'); | |
| $skippedFilePath = $file->getPathname(); | |
| $skippedFileReplaced = str_replace(__DIR__,'$PROJECT_DIR$',$skippedFilePath); | |
| $skippedFile->addAttribute('file',$skippedFileReplaced); | |
| } | |
| $file = fopen ($xmlConfigurationPath, "w"); | |
| fwrite($file, $xml->asXML()); | |
| fclose ($file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment