用 grunt 运行 php 脚本

Ste*_*efR 1 php gruntjs grunt-contrib-watch

我的服务器上有一个 php 脚本(我们称之为 /test.php)。在 Grunt 自动解析我的 SCSS 和 JS 之后,我想运行这个 test.php 脚本(它会重置我的内存缓存)。我似乎找不到办法做到这一点。有人有线索吗?

小智 5

您可以使用grunt-shell通过在 cli 上运行您的 php 脚本php -f your-script.php

grunt.initConfig({
    shell: {
        php: {
            command: 'php -f your-script.php'
        }
    }
}

grunt.registerTask('runTestPhp', ['shell:php']);
Run Code Online (Sandbox Code Playgroud)

如果您不想通过 cli 运行 php 脚本,请查看grunt-php