Search code examples
phpgruntjsgrunt-contrib-watch

Run php script with grunt


I have a php script (lets call this /test.php) on my server. After Grunt automatically has parsed my SCSS and JS I would like to run this test.php script (it resets my memcache). I can't seem to find a way to do this. Anyone got a clue?


Solution

  • You can use grunt-shell to run your php script on cli via php -f your-script.php

    grunt.initConfig({
        shell: {
            php: {
                command: 'php -f your-script.php'
            }
        }
    }
    
    grunt.registerTask('runTestPhp', ['shell:php']);
    

    If you don't want to run your php script through cli, have a look at grunt-php.