Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Last active January 1, 2016 08:19
Show Gist options
  • Select an option

  • Save tegansnyder/8117109 to your computer and use it in GitHub Desktop.

Select an option

Save tegansnyder/8117109 to your computer and use it in GitHub Desktop.
Format the output of the n98-magerun.phar config:get web/ to a csv
<?php
/*
n98-magerun url formater to CSV
usuage: n98-magerun.phar config:get web/ | php n98-urls-to-csv.php > csv-of-urls.csv
*/
$str = stream_get_contents(fopen("php://stdin", "r"));
$str = str_replace("+","",$str);
$str = str_replace("-","",$str);
$str = str_replace("|",",",$str);
$str = str_replace(" ","",$str);
$str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
$str_array = explode("\n", $str);
foreach ($str_array as $nstr) {
if (!empty($nstr)) {
$nstr = rtrim($nstr, ',');
$nstr = ltrim($nstr, ',');
echo $nstr . PHP_EOL;
}
}
@tegansnyder

Copy link
Copy Markdown
Author

Scratch that looks like n98-magerun has a nice feature included to do this:

n98-magerun.phar config:get web/ --magerun-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment