Grunt doesn't work with php shell_exec ()

Purpose: Start grunt process in php project on button click. I have one grunt file to handle the build process for multiple Wordpress themes. It works and I am passing the theme name from the form dropdown like grunt.option ('themeKey').

Problem. I have a working command that works in the terminal and a button to run it, but it doesn't actually run when the button is pressed.

    <?php
      if(isset($_POST['formTheme'])){
        $grunttheme = $_POST['formTheme'];
        $process = 'cd /Applications/XAMPP/xamppfiles/htdocs/grunt && grunt build --themeKey="'.$grunttheme.'"';
        echo shell_exec($process);
      }
    ?>

      

Mistake: sh: grunt: command not found

What do I need to do to get this command to run from index.php? I have tried several different options, ripped from different php docs and stackoverflow entries like aliases, PATH, etc. I'm new to php and still pretty green with the command line, so I might just have bad syntax or miss an important piece. Any help is appreciated, thanks!

+3


source to share





All Articles