Ain
Ain

Reputation: 13

How to run php file with grunt?

I have a yeoman generator that works great with html files and serve livereload using grunt serve. my problem is how can i run a php file using grunt serve? my connect code is

   express: {
      all: {
        options: {
          port: 9000,
          hostname: '0.0.0.0',
          bases:'<%= yeoman.app %>',
          livereload: true
         }
  }
},

Upvotes: 1

Views: 530

Answers (1)

user3270453
user3270453

Reputation:

Hey i don't know but maybe something similar might work for you as i don't know what you are really trying to do.

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    php: {
        dist: {
            options: {
                port: 8080,
                base: 'web',
                open: true,
                keepalive: true
            }
        }
    },
    phpcs: {
        application: {
            dir: 'src'
        },
        options: {
            bin: 'phpcs',
            standard: 'PSR-MOD'
        }
    },
    phplint: {
        options: {
            swapPath: '/tmp'
        },
        all: ['src/*.php', 'src/base/*.php', 'src/config/*.php', 'src/controller/*.php', 'src/model/*.php']
    },
    phpunit: {
        unit: {
            dir: 'tests/unit'
        },
        options: {
            bin: 'phpunit',
            bootstrap: 'tests/Bootstrap.php',
            colors: true,
            testdox: true
        }
    },
    php_analyzer: {
        application: {
            dir: 'src'
        }
    }
  });

  grunt.loadNpmTasks('grunt-phpcs');
  grunt.loadNpmTasks('grunt-php');
  grunt.loadNpmTasks('grunt-phplint');
  grunt.loadNpmTasks('grunt-phpunit');
  grunt.loadNpmTasks('grunt-php-analyzer');
  grunt.registerTask('precommit', ['phplint:all', 'phpunit:unit']);
  grunt.registerTask('default', ['phplint:all', 'phpcs', 'phpunit:unit', 'php_analyzer:application']);
  grunt.registerTask('server', ['php']);
};

Upvotes: 1

Related Questions