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
command-line node.js php shell gruntjs


source to share


No one has answered this question yet

Check out similar questions:

4270
Link. What does this symbol mean in PHP?
2776
How can I prevent SQL injection in PHP?
2414
Why shouldn't I use the mysql_ * functions in PHP?
2335
Removing an element from an array in PHP
2024
How do you parse and process HTML / XML in PHP?
1906
How does PHP foreach work?
1387
startsWith () and endsWith () functions in PHP
1203
NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack
509
Rough watch error - Waiting ... Fatal error: see ENOSPC
311
PHP shell_exec () vs exec ()



All Articles
Loading...
X
Show
Funny
Dev
Pics