grunt-php-set-constant

Set PHP constants to a defined values in PHP files.

grunt-set-constant

Set a constant in a php file to the value indicated.

This is a multi task.

This supports single or double quotes. Heredoc and nowdoc within the define are not supported. String constants are supported.

Example usage within grunt init:

    setPHPConstant: {
        stage: {
            constant    : 'ENV',
            value       : 'staging',
            file        : 'temp/myfile.php'
        }
    }

The above would change the source of temp/myfile.php. It would change something like

define('ENV', 'blah');

to

define('ENV', 'staging');
  • TODO:
    • support constants other than strings
    • implement tests