From 1fac6b5a91ad38a2d83418ec765d9e654b4a3ebf Mon Sep 17 00:00:00 2001 From: waxblur Date: Fri, 10 Aug 2018 10:52:49 +0200 Subject: [PATCH] Update helpers.php Hey! I use "acacha/admin-lte-template-laravel" package and used the command "php artisan make:route about" and get an error because i use Windows 10 and "sed" is not installed by default. Is it possible to use php instead of sed? --- src/helpers.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/helpers.php b/src/helpers.php index de3176d..95cd1cc 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -108,16 +108,22 @@ function add_text_into_file($mountpoint, $textToAdd, $file) */ function add_file_into_file($mountpoint, $fileToInsert,$file, $outputFile = null) { - if ($outputFile != null) { - passthru( - 'sed -e \'/'.$mountpoint.'/r'.$fileToInsert.'\' '. - $file.' > '.$outputFile, $error); - } else { - passthru( - 'sed -i \'/'.$mountpoint.'/r'.$fileToInsert.'\' '.$file, $error); - } - - return $error; + // use PHP functions not sed because sed ist not installed on + // windows by default + $fileNewContent = str_replace($mountpoint, $mountpoint."\n".file_get_contents($fileToInsert), file_get_contents($file)); + file_put_contents($file, $fileNewContent); + + return ''; + +// if ($outputFile != null) { +// passthru( +// 'sed -e \'/'.$mountpoint.'/r'.$fileToInsert.'\' '.$file.' > '.$outputFile, $error); +// } else { +// passthru( +// 'sed -i \'/'.$mountpoint.'/r'.$fileToInsert.'\' '.$file, $error); +// } +// +// return $error; } }